相关库安装
一.请求库安装
request安装
pip install requests
selenium安装
pip install selenium
ChromeDriver的安装
""" window安装 """ # 下载与谷歌浏览器对应的版本 http://npm.taobao.org/mirrors/chromedriver/ # 环境配置 win: 将解压文件拖到python的scripts目录下 """ linux安装 """ # centos安装谷歌浏览器 yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm yum install mesa-libOSMesa-devel gnu-free-sans-fonts wqy-zenhei-fonts # linux查看谷歌版本 rpm -qa|grep google-chrome # linux下载对应版本的chromedriver wget http://npm.taobao.org/mirrors/chromedriver/版本/chromedriver_linux64.zip #解压后将可执行文件放入/usr/bin # 测试 from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_argument('--headless') # 设置无界面 options.add_argument('--no-sandbox') # root用户下运行代码需添加这一行 driver = webdriver.Chrome(options=options) driver.get("https://www.baidu.com") print(driver.page_source) driver.quit()
安装phantomjs
# 下载 wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2 # 解压 tar -xvf phantomjs-1.9.7-linux-x86_64.tar.bz2 # 设置软连接 ln -sf /usr/local/src/phantomjs/bin/phantomjs /usr/bin/phantomjs # 测试 phantomjs -v
aiohttp安装
pip install aiohttp
二.解析库安装
lxml安装
pip install lxml
beautiful soup安装
pip install beautifulsoup4
pyquery安装
pip install pyquery
tesserocr安装
# OCR 光学字符识别,通过扫描字符,然后通过其形状将其翻译成电子文本的过程 yum install -y tesseract # 如果出现Trying other mirror. yum clean all yum makecache yum update # 查看支持的语言 tesseract --list-langs # 加载语言包 git clone https://github.com/tesseract-ocr/tessdata.git mv tessdata/* /usr/share/tesseract/tessdata

浙公网安备 33010602011771号