在学习写爬虫爬取小说时无法启动Chrome浏览器,并且报错
'chromedriver' executable needs to be in PATH
爬虫代码如下:
# from bs4 import BeautifulSoup
# from selenium import webdriver
#
# if __name__ == '__main__':
# url = 'https://www.biqukan.com/1_1094/5403177.html'
# driver= webdriver.Chrome()
# req = driver.get(url)
# html = driver.page_source
# bf = BeautifulSoup(html, "html.parser")
# texts = bf.find_all('div', class_="showtxt")
# print(texts[0].text.replace('\xa0'*8, '\n'))
解决办法如下:
第一步:下载chromedriver
chromedriver的下载地址:
http://chromedriver.storage.googleapis.com/index.html
这里要注意:chromedriver的版本有很多,