Skip to content

Instantly share code, notes, and snippets.

@kazz187
Created February 25, 2014 04:17
Show Gist options
  • Save kazz187/9202601 to your computer and use it in GitHub Desktop.
Save kazz187/9202601 to your computer and use it in GitHub Desktop.
def self.get_user_icon_url(screen_name)
if screen_name.nil?
return nil
end
open_url = "https://twitter.com/#{screen_name}"
require 'open-uri'
begin
doc = open(open_url)
rescue
logger.debug "Can't open #{open_url}"
return nil
end
if doc.nil?
return nil
end
picture_tags = Hpricot(doc)/"a.profile-picture"
if picture_tags.nil? && picture_tags.empty?
return nil
end
picture_tags.first["data-url"]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment