Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 13:56
What would you like to do?
Finds the source of a retweet chain.
require 'nokogiri'
require 'httparty'
def next_tweet tweet_url
response = HTTParty.get tweet_url
tweet_link = Nokogiri::XML( response ).xpath( "//a/@data-expanded-url" ).first
p tweet_link.value unless tweet_link.nil?
def find_source url
tweet = next_tweet( url )
tweet ? find_source( tweet ) : url
find_source ""
Copy link

def find_source url
another_tweet = next_tweet url
another_tweet ? find_source another_tweet : url

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment