写一个基本的爬虫:
from selenium import webdriverdef main(url):driver = webdriver.Chrome()driver.get(url)html = driver.page_sourcedriver.close()soup = BeautifulSoup(html)title = soup.title.stringdescription = soup.find(attrs={"name": "description"})['content']# keywords = soup.find(attrs={"name": "keywords"})['content']print('title:', title)print('description:', description)# print('keywords:', keywords)
安装 chromedriver
On Ubuntu:
sudo apt install chromium-chromedriver
On Debian:
sudo apt install chromium-driver
On macOS install https://brew.sh/ then do
brew cask install chromedriver
