python3爬虫学习笔记(一)相关库的安装

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_33532713/article/details/86480661

请求库的安装

  1. requests的安装
    pip3 install requests
    中文文档:http://docs.python-requests.org/zh_CN/latest/
  2. Selenium的安装
    pip3 install selenium
    中文文档:https://selenium-python-zh.readthedocs.io/en/latest/
  3. chromedriver的安装
    首先点击Chrome菜单“帮助”–>“关于 Google Chrome(G)”,查看版本号。
    chromedriver镜像站下载 对应版本号的安装包文件,windows直接解压到Anaconda的Scripts文件夹中即可。
    在命令行输入chromedriver,随后执行下列python代码:
In [1]: from selenium import webdriver
In [2]: brower = webdriver.Chrome()

运行之后,会出现一个空白的chrome浏览器,则证明所有的配置都没有问题。

  1. GeckoDriver的安装
    用于火狐浏览器,同上面的chromedriver一样的功能。
    安装包下载地址:https://github.com/mozilla/geckodriver/releases
    直接解压exe文件到Anaconda的Scripts文件夹下。
In [1]: from selenium import webdriver
In [2]: brower = webdriver.Firefox()
  1. PhantomJS的安装
    下载地址:http://phantomjs.org/download.html
    下载完后解压到目标文件夹,然后配置到path环境变量中。
    在命令行输入phantomjs,如果进入到phantomjs的命令行,则说明配置成功。
  2. aiohttp的安装
    官方文档:https://aiohttp.readthedocs.io/en/stable/
    安装 : pip3 install aiohttp
    另外,官方还推荐安装如下两个库:字符编码检测库cchardet和加速DNS的解析的库aiodns
    pip3 install cchardet aiodns

解析库的安装

  1. lxml的安装
    官网: https://lxml.de/
    安装:pip3 install lxml
  2. Beautiful Soup的安装
    中文文档:https://www.crummy.com/software/BeautifulSoup/bs4/doc.zh/
    安装:pip3 install beautifulsoup4
  3. pyquery的安装
    官方文档:https://pyquery.readthedocs.io/en/latest/
    安装:pip3 install pyquery
  4. tesserocr的安装
    下载地址:https://digi.bib.uni-mannheim.de/tesseract/
    github: https://github.com/tesseract-ocr
    点击下载完成之后,安装软件到目标文件夹,然后再安装tesserocr即可。
    pip3 install tesserocr pillow

以上内容全部摘自崔庆才的《python3网络爬虫开发实战》

猜你喜欢

转载自blog.csdn.net/qq_33532713/article/details/86480661