DEV Community

Discussion on: Scraping every post on an Instagram profile with less than 10 lines of Python

 
karisjochen profile image
karisjochen

oh I guess I should also mention that my end goal is to collect data similar to the data you analyzed in your donald trump post. I saw you published a notebook of the analysis code (thank you!) but didn't see a line-by-line on how you got that data.

Thread Thread
 
chrisgreening profile image
Chris Greening

scraped Post objects contain the scraped data as instance attributes! Try using the to_dict method on one of the Post's and it should return a dictionary with the data it scraped for that Post. The key/values of the returned dict will correspond one-to-one with the available instance attributes

I'll take a look at the login_first bug rn and see if I can replicate it, it might be on the library's end! Instagram has been making a lot of changes the last month or so and have been making it increasingly harder to scrape

Thread Thread
 
chrisgreening profile image
Chris Greening

ahhh okay, so when you set login_first=False, Instagram is still redirecting to the login page automatically but instascrape is trying to start scrolling immediately which results in an empty list since there are no posts rendered on the page

to access dynamically rendered content like posts you're pretty much always gonna have to be logged in so it's best to leave login_first as True unless you're chaining scrapes and your webdriver is already logged in manually

Thread Thread
 
karisjochen profile image
karisjochen

amazing thank you! So I was able to get my first 10 posts no problem by specifying amount=10 but then I tried to do all ~500 pictures and after 232 pictures I came across this error:

ConnectionError: ('Connection aborted.', OSError("(54, 'ECONNRESET')"))

Im guessing this means instagram blocked my request? Have you come across this issue?