建议更换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. RK3288的gpio设置【转】

    本文转载自:http://blog.csdn.net/keleming1/article/details/51034766 转http://www.360doc.com/content/14/1227 ...

  2. Maven 项目管理 —— 安装与配置

    Maven 是一种全新的项目构建方式,基于项目对象模型(POM,Project Object Model)的思想,Maven 可以管理项目的整个生命周期,包括编译.构建(build).测试.发布以及报 ...

  3. bzoj3295 洛谷P3157、1393 动态逆序对——树套树

    题目:bzoj3295 https://www.lydsy.com/JudgeOnline/problem.php?id=3295 洛谷 P3157(同一道题) https://www.luogu.o ...

  4. 如何在linux 32位机器编译64位程序

    编译64位程序,不一定要编译机器是64位的,但是32位机器默认安装的gcc编译环境还是不能用来编译64位程序. 编译64位程序,需要加上-m64编译器参数,默认安装的gcc已经支持该参数,但是缺少64 ...

  5. android 手机上运行图像算法

    在pc上调试好的图像处理算法想要在android手机上跑一下看看速度需要一下几个步骤 1.建立一个android application,通过ndk调用你写好的图像算法的c/c++ code 2. 然 ...

  6. navicat导入.sql文件出错2006-MySQLserver has gone away

    方式一(验证无误): 找到mysql安装目录下的my.ini配置文件,加入以下代码: max_allowed_packet=500M wait_timeout=288000 interactive_t ...

  7. svchost.exe 占用内存过多

    http://www.tomshardware.com/forum/20583-63-svchost-netsvcs-speed By Lokesh Chandra: Just Go to Contr ...

  8. 【转载】Java - Wait & Notify

    [本文转自]http://www.cnblogs.com/dolphin0520/p/3920385.html 这三个方法的文字描述可以知道以下几点信息: 1)wait().notify()和noti ...

  9. 网站开发综合技术 HTML

    HTML            内容(Hyper Text Markup Language,超文本标记语言) CSS             网页美化 Javascript      脚本语言 第一部 ...

  10. Xml学习笔记(3)利用递归解析Xml文档添加到TreeView中

    利用递归解析Xml文档添加到TreeView中 private void Form1_Load(object sender, EventArgs e) { XmlDocument doc = new ...