Skip to content

Instantly share code, notes, and snippets.

@dannyvassallo
Created October 27, 2016 03:39
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 dannyvassallo/e3b00cb7c1002fda891c3f9d8e864393 to your computer and use it in GitHub Desktop.
Save dannyvassallo/e3b00cb7c1002fda891c3f9d8e864393 to your computer and use it in GitHub Desktop.
require "csv"
require "insta_scrape"
def appendRowToCsv(row)
CSV.open("instagram_posts.csv", "a+",) do |csv|
csv << row
end
end
# create headers
appendRowToCsv(['image', 'link']);
# iterate through posts appending each new photo to csv
scrape_result = InstaScrape.hashtag("test") #change the scrape method / tag to what you want
scrape_result.each do |post|
appendRowToCsv([post.image, post.link])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment