Я использую Python и Selenium, чтобы попытаться очистить все ссылки с страницы результатов определенной страницы поиска. Независимо от того, что я ищу на предыдущем экране, URL-адрес для любого поиска на странице результатов: «https://chem.nlm.nih.gov/chemidplus/ProxyServlet» Если я использую Selenium для автопоиска, попробуйте прочитать этот URL-адрес в BeautifulSoup, я получаю HTTPError: HTTP Error 404: Не найденНевозможно идентифицировать веб-страницу в BeautifulSoup по URL
Вот мой код:
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
from urllib.request import urlopen
from bs4 import BeautifulSoup
import csv
# create a new Firefox session
driver = webdriver.Firefox()
# wait 3 seconds for the page to load
driver.implicitly_wait(3)
# navigate to ChemIDPlus Website
driver.get("https://chem.nlm.nih.gov/chemidplus/")
#implicit wait 10 seconds for drop-down menu to load
driver.implicitly_wait(10)
#open drop-down menu QV7 ("Route:")
select=Select(driver.find_element_by_name("QV7"))
#select "inhalation" in QV7
select.select_by_visible_text("inhalation")
#identify submit button
поиск = "/ HTML/тело/дела [2]/дела/дела [2]/дела/дела [2]/форма/div [1]/div/span/button [1] "
#click submit button
driver.find_element_by_xpath(search).click()
#increase the number of results per page
select=Select(driver.find_element_by_id("selRowsPerPage"))
select.select_by_visible_text("25")
#wait 3 seconds
driver.implicitly_wait(3)
#identify current search page...HERE IS THE ERROR, I THINK
url1="https://chem.nlm.nih.gov/chemidplus/ProxyServlet"
page1=urlopen(url1)
#read the search page
soup=BeautifulSoup(page1.content, 'html.parser')
Я подозреваю, что это имеет какое-то отношение к proxyserver, и Python не получает необходимую информацию для идентификации веб-сайта, но я не уверен, как обойти это. Спасибо заранее!