Skip to content

Instantly share code, notes, and snippets.

@audibleblink
Last active Aug 29, 2015
Embed
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?
end
def find_source url
tweet = next_tweet( url )
tweet ? find_source( tweet ) : url
end
find_source "https://twitter.com/waneka/status/433519520842395648"
@elreimundo
Copy link

elreimundo commented Feb 13, 2014

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

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