Skip to content

Instantly share code, notes, and snippets.

@run26kimo
Created October 6, 2016 04:33
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 run26kimo/8b1cae777243a5e1fab319a67de020e6 to your computer and use it in GitHub Desktop.
Save run26kimo/8b1cae777243a5e1fab319a67de020e6 to your computer and use it in GitHub Desktop.
Parse instagram hashtag image
hashtag = 'car'
url = "https://www.instagram.com/explore/tags/#{hashtag}/"
page = HTTParty.get(url)
body = Nokogiri::HTML.parse(page.body, nil, 'utf-8').text
reg = /display_src\": \"(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})\"}/
images = body.scan(reg).map{|s| s[0] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment