Я использую автономный Chrome Selenium в Docker и могу подключиться к нему, запуская локальное приложение Python.
мое приложение выглядит так:
Код: Выделить всё
def web_scrape():
url = "https://who.maps.arcgis.com/apps/opsdashboard/index.html#/ead3c6475654481ca51c248d52ab9c61"
#setup webdriver
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('--headless')
options.add_argument('--disable-dev-shm-usage')
options.add_argument("--remote-debugging-port=9222")
driver = webdriver.Remote(command_executor="http://localhost:4444/wd/hub", desired_capabilities=options.to_capabilities())
driver.get(url)
time.sleep(20)
html = driver.execute_script("return document.documentElement.outerHTML")
#Use BeautifulSoup for working with html
soup = BeautifulSoup(html, "html.parser")
covid_soup = soup.find("div", id="ember44").div.nav.find_all("span", class_="flex-horizontal")
covid_dict = {}
for i in covid_soup:
country = i.find("strong").get_text(strip=True)
country = clean_country_name(country)
imgURL = i.p.find_next("p").find_next("p").find("img").get('src')
color = get_covid_color(imgURL)
covid_dict[country] = color
save_to_json(covid_dict)
есть ли у кого-нибудь предложения, что может быть не так?
Подробнее здесь: https://stackoverflow.com/questions/653 ... retryerror
Мобильная версия