Код: Выделить всё
import requests
from selenium import webdriver
from selenium.webdriver.common.by import By
import urllib
import time
import os
path = "C:/Users/micha/Documents/PythonProgramming/IG"
gifname = "captcha"
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(options=chrome_options)
# Create url variable containing the webpage for a Google image search.
url = ("https://www.infamousgangsters.com/site.php?page=bulletfactory")
# Find the images.
imgResults = driver.find_elements(By.XPATH,"/html/body/div/table/tbody/tr/td/table/tbody/tr/td[2]/div[@class='spacer']/table[2]/tbody/tr/td[@class='bodymain']/div[2]/form/img/@src")
# Access and store the scr list of image url's.
src = []
for img in imgResults:
src.append(img.get_attribute('src'))
# Retrieve and download the images.
for i in range(len(src)): urllib.request.urlretrieve(str(src[i]),"sample_data/captchas{}.gif".format(i))
with open(os.path.join(path, gifname), 'wb') as f:
driver.close()
Подробнее здесь: https://stackoverflow.com/questions/787 ... uce-an-act