Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda