【发布时间】:2019-09-16 09:30:18
【问题描述】:
试图抓取 table-tr-td[2] 中给出的链接,但面临以下错误 --selenium.common.exceptions.InvalidSessionIdException: Message: invalid session id。
我尝试过使用 selenium webdriver,但没有得到 seesion 错误的问题。
from bs4 import BeautifulSoup
from selenium import webdriver
url="https://www.zaubacorp.com/company-list"
driver = webdriver.Chrome(r'C:\chromedriver.exe')
driver.get(url)
driver.close()
soup = BeautifulSoup(driver.page_source,'html.parser')
table = soup.find('table',{'id':'table'})
body = table.find('tbody')
for links in body.find_all('a'):
print(links['href'])
请帮我解决这个问题。提前谢谢。
【问题讨论】:
标签: python-3.x beautifulsoup selenium-chromedriver