Hice un rastreador de imágenes usando la función de búsqueda de etiquetas de Instagram con selenio. Y agregó una función de desplazamiento. Sin embargo, existía el problema de que solo se podían guardar un máximo de 50 imágenes. Entonces, si reviso la lista de publicaciones después de desplazarme, el elemento anterior se elimina y el índice comienza desde 1 nuevamente. ¿Hay alguna forma de guardar más fotos? ¿Es porque Instagram lo restringe o las especificaciones de mi computadora son malas?
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()