Skip to content

Instantly share code, notes, and snippets.

@audibleblink
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save audibleblink/8963964 to your computer and use it in GitHub Desktop.
Save audibleblink/8963964 to your computer and use it in GitHub Desktop.
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

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