Last active
August 29, 2015 13:56
-
-
Save audibleblink/8963964 to your computer and use it in GitHub Desktop.
Finds the source of a retweet chain.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
def find_source url
another_tweet = next_tweet url
another_tweet ? find_source another_tweet : url
end