建议更换pip源到国内镜像,下载会快很多:https://www.cnblogs.com/believepd/p/10499844.html

requests

pip3 install requests

selenium

pip3 install selenium

安装好后,测试一下:

from selenium import webdriver
driver = webdriver.Chrome()

执行后报错了:

需要安装chromedriver才能完成chrome浏览器的驱动。

可以从这里下载适合自己的chromedriver(需要对应自己的chrome版本!!!):https://npm.taobao.org/mirrors/chromedriver

比如我的是windows,解压后将chromedriver.exe放到某个配置好环境变量的目录下。

运行:

from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.baidu.com")
print(driver.page_source)

可以看到,自动打开百度并获取到了源代码。

但是,在做爬虫的时候,一直打开浏览器是不方便的,这时就需要一个没有界面的"浏览器"----phantomjs。

下载phantomjs:http://phantomjs.org/download.html

解压后,将bin目录配置到环境变量中。

from selenium import webdriver
driver = webdriver.PhantomJS(executable_path=r"D:\phantomjs-2.1.1-windows\bin\phantomjs.exe")
driver.get("https://www.baidu.com")
print(driver.page_source)

lxml

pip3 install lxml

beautifulsoup

pip3 install beautifulsoup4
from bs4 import BeautifulSoup
soup = BeautifulSoup("<html></html>", "lxml")

pyquery

pip3 install pyquery
from pyquery import PyQuery as pq
doc = pq("<html>hello!</html>")
result = doc("html").text()
print(result) # hello!

pymongo

pip3 install pymongo
import pymongo
client = pymongo.MongoClient("localhost")
db = client["test_db"]
db["table"].insert({"name": "pd"})
result = db["table"].find_one({"name": "pd"})
print(result)

jupyter

pip3 install jupyter

相当于一个记事本,它是运行在网页端的。

在cmd中输入:jupyter notebook,就会自动打开浏览器。点击new python3,即可在网页上运行代码。

Python爬虫常用库安装的更多相关文章

  1. 爬虫-Python爬虫常用库

    一.常用库 1.requests 做请求的时候用到. requests.get("url") 2.selenium 自动化会用到. 3.lxml 4.beautifulsoup 5 ...

  2. python爬虫常用库和安装 -- windows7环境

    1:urllib  python自带 2:re      python自带 3:requests     pip install requests 4:selenium      需要依赖chrome ...

  3. Python爬虫常用模块安装

    安装:pip3 install requestspip3 install seleniumpip3 install bs4pip3 install pyquerypip3 install pymysq ...

  4. Python 爬虫常用库(九)

  5. python常用库安装网址

    python常用库安装网址如下: http://pypi.python.org/pypi

  6. Python爬虫—requests库get和post方法使用

    目录 Python爬虫-requests库get和post方法使用 1. 安装requests库 2.requests.get()方法使用 3.requests.post()方法使用-构造formda ...

  7. python爬虫---selenium库的用法

    python爬虫---selenium库的用法 selenium是一个自动化测试工具,支持Firefox,Chrome等众多浏览器 在爬虫中的应用主要是用来解决JS渲染的问题. 1.使用前需要安装这个 ...

  8. Python爬虫Urllib库的高级用法

    Python爬虫Urllib库的高级用法 设置Headers 有些网站不会同意程序直接用上面的方式进行访问,如果识别有问题,那么站点根本不会响应,所以为了完全模拟浏览器的工作,我们需要设置一些Head ...

  9. Python爬虫Urllib库的基本使用

    Python爬虫Urllib库的基本使用 深入理解urllib.urllib2及requests  请访问: http://www.mamicode.com/info-detail-1224080.h ...

随机推荐

  1. ThinkAndroid框架

    ThinkAndroid简介 ThinkAndroid是一个免费的开源的.简易的.遵循Apache2开源协议发布的Android开发框架,其开发宗旨是简单.快速的进行 Android应用程序的开发,包 ...

  2. luogu3942将军令

    https://www.zybuluo.com/ysner/note/1302132 题面 在大小为\(n\)的树上选择尽量少的点,使得所有未选择的点距离选择了的点小于等于\(k\). \(n\leq ...

  3. POJ1279 Art Gallery 多边形的核

    POJ1279 给一个多边形 求它的核的面积 所谓多边形的核 是多边形中的一个点集 满足其中的点与多边形边上的点的连线全部在多边形中 用多边形的每一条边所在的直线去切整个坐标平面 得到的一个凸包就是核 ...

  4. 再读headfirst-原则与模式摘录

    原则 1.找到原则中可能需要变化之处,把它们独立出来,不要和那些不需要变化的代码混在一起 2.针对接口编程,而不是针对实现编程 3.多用组合,少用继承 4.依赖倒置原则:要依赖抽象,不要依赖具体类(不 ...

  5. STM32:片上Flash 操作

    之前IAP时候记录过一些,今天对特定地方写又加深了印象,写与擦除都需要先unclock //读取指定地址的半字(16位数据) //faddr:读地址(此地址必须为2的倍数!!) //返回值:对应数据. ...

  6. Python 私有化类的属性

    class MandgerSec: def __init__(self,name,gender,level): self.type=("fire",None) self.name= ...

  7. 如何精通javascript

    http://stackoverflow.com/questions/2628672/what-should-every-javascript-programmer-know Not jQuery. ...

  8. 《Effective C++》笔记:III(转载)

    转自:http://www.cnblogs.com/destino74/p/3960802.html 条款5:Know what functions C++ silently writes and c ...

  9. E20171226-hm

    stack n.栈 heap  n.堆 backtracking 回溯法,後戻り storage  n. 贮存; 贮藏; 储藏处,仓库; 贮存器,蓄电(瓶); ストレージ

  10. bzoj 2662: [BeiJing wc2012]冻结【分层图+spfa】

    死活想不到分层图emmm 基本想法是建立分层图,就是建k+1层原图,然后相邻两层之间把原图的边在上一层的起点与下一层的终点连起来,边权为val/2,表示免了这条边的边权,然后答案就是第0层的s到k层的 ...