笔记2-请求库安装

作者: 路由心定 | 来源:发表于2019-01-08 10:18 被阅读0次

    1.Requests安装

    1.pip3 install requests
    2.验证安装

    $python3
    >>>import requests
    
    图-1.png

    3.安装过程中遇到的问题

    #问题1
    pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
    Collecting requests
      Could not fetch URL https://pypi.python.org/simple/requests/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
      Could not find a version that satisfies the requirement requests (from versions: )
    No matching distribution found for requests
    #问题1-解决方法:依次执行以下步骤
    --1--:重新进入python3目录
    --2--:./configure --with-ssl
    --3--:make
    --4--:sudo make install
    

    2.wheel安装

    1.pip3 install wheel

    3.Selenium安装

    1.Selenium--自动化 测试工具--主要用作驱动浏览器
    2.pip3 install selenium
    3.验证安装

    $python3
    >>> import selenium
    
    图-2.png

    4.GeckoDriver安装

    1.下载地址

    https://github.com/mozilla/geckodriver/releases
    
    图-3.png
    2.环境变量配置
    --方法1:
    sudo mv geckodriver /usr/bin
    

    3.验证

    #调用火狐浏览器,会打开空白页面
    from selenium import webdriver
    driver=webdriver.Firefox()
    

    5.PhantomJS安装

    1.无界面、可脚本编程、WebKit浏览器引擎
    2.安装步骤

    --1--:wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
    --如果下载提示找不到资源,登录官网下载http://phantomjs.org/download.html
    --2--:tar -xjvf phantomjs-2.1.1-linux-x86_64.tar.bz2
    --3--:sudo ln -s 下载目录/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
    

    3.验证安装

    $phantomjs -v
    
    图-4.png

    6.aiohttp安装

    1.requests库是一个阻塞式HTTP请求库,当发出请求时程序会一直等待响应直到得到响应,比较耗时所以需要一个异步Web服务库-aiohttp
    2.pip安装

    1.安装aiohttp
    pip3 install  aiohttp
    2.官方推荐安装字符编码检测库、加速DNS解析库aiodns
    pip3 install cchardet aiodns
    

    3.验证安装

    $python3
    >>> import aiohttp
    
    图-5.png

    7.讨论交流

    q:725054061
    

    相关文章

      网友评论

        本文标题:笔记2-请求库安装

        本文链接:https://www.haomeiwen.com/subject/cphhrqtx.html