Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
Why Selenium only crawls 50 Instagram photos?

I made an image crawler using instagram's tag search function with selenium. And added a scroll function. However, there was a problem that only a maximum of 50 images could be saved. So, if I check the list of posts after scrolling, the previous element is deleted and the index starts from 1 again. Is there any way to save more pictures? Is it because Instagram restricts it or my computer specs are bad?

enter image description here enter image description here

SCROLL_PAUSE_TIME = 3
while True:
    
    html = driver.page_source
    soup = BeautifulSoup(html, 'html.parser')
    time.sleep(3)
    
    posts = soup.select('.v1Nh3.kIKUG._bz0w')
    time.sleep(5)
    for v in range(1, len(posts)):
        print("\n==== index ==== : ", v)

    last_height = driver.execute_script('return document.body.scrollHeight')
    driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
    time.sleep(SCROLL_PAUSE_TIME)
    new_height = driver.execute_script("return document.body.scrollHeight")

    if new_height == last_height:
        driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
        time.sleep(SCROLL_PAUSE_TIME)
        new_height = driver.execute_script("return document.body.scrollHeight")

        if new_height == last_height:
            break
        else:
            last_height = new_height
            continue

for index, post in enumerate(posts):
    print('https://www.instagram.com/' + post.a['href'])
    imgUrl = post.select_one('.KL4Bh').img['src']
    with urlopen(imgUrl) as f:  
        with open('./22ss/' + plusUrl + str(index) + '.jpg', 'wb') as h:  
            image = f.read()  
            h.write(image)  

    print(imgUrl)
    print()
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!