建议更换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. T3 最短路 line

    T3 最短路 line [问题描述] 给定一个 n 个点,m 条边的有向图,每个点有一个权值 a[i],表示这个点要到达多少次,1 为起始点,从 1 到 i 的距离为 d[i],请你输出∑a[i]*d ...

  2. 洛谷 P1570【NOIP2013】花匠

    题目描述 花匠栋栋种了一排花,每株花都有自己的高度.花儿越长越大,也越来越挤.栋栋决定 把这排中的一部分花移走,将剩下的留在原地,使得剩下的花能有空间长大,同时,栋栋希 望剩下的花排列得比较别致. 具 ...

  3. 配置文件git config介绍

    Git有一个工具被称为git config,它允许你获得和设置配置变量:这些变量可以控制Git的外观和操作的各个方面. 一. 配置文件的存储位置 这些变量可以被存储在三个不同的位置: 1./etc/g ...

  4. Shell 通配符、元字符、转义符*****

    说到shell通配符(wildcard),大家在使用时候会经常用到.下面是一个实例: 1   1 2 3 4 [chengmo@localhost ~/shell]$ ls a.txt  b.txt  ...

  5. Git-flow 一个简单高效的Git工作流

    背景 由于Git的分支比SVN更好管理且更易使用,最近团队从SVN迁移到Git,需要重新规划开发流程,最终确定使用Git-flow工作流,这是目前比较流行的一种分支模型,下面是Git-flow的简易流 ...

  6. Shell脚本下条件测试(eq.ne.....)(转载)

    转载:http://cxj632840815.blog.51cto.com/3511863/1168709 Shell编程中的条件测试 在Linux编程中经常会用到判断数值的大小,字符串是否为空这样或 ...

  7. Django day 36 支付宝支付,微信推送

    一:支付宝支付, 二:微信推送

  8. Light 1289 - LCM from 1 to n (位图标记+素数筛选)

    题目链接: http://www.lightoj.com/volume_showproblem.php?problem=1289 题目描述: 给出一个n,求出lcm(1,2,3......n)为多少? ...

  9. python中os模块中文帮助

    python中os模块中文帮助   python中os模块中文帮助文档文章分类:Python编程 python中os模块中文帮助文档 翻译者:butalnd 翻译于2010.1.7——2010.1.8 ...

  10. LR接口测试---Java Vuser之jdbc查询(调试前)

    在eclipse下编写好的代码: import lrapi.lr; import java.sql.Connection; import java.sql.DriverManager; import ...