urllib
import urllib
import urllib.request
urllib.request.urlopen('http://www.baidu.com')
import re
request
#请求
pip3 install request
import request
selenium
#渲染包
import selenium
from selenium import webdriver
#需手动下载chromedriver http://chromedriver.chromium.org/downloads
driver = webdriver.Chrome()
#get网页
driver.get('http://www.baidu.com')
#获取页面代码
driver.page_source
#为了避免获取网页弹出浏览器窗口,需下载phantomjs并配置PATH
#官网地址下载 http://phantomjs.org/download.html
from selenium import webdriver
drvier = webdriver.PhantomJS()
driver.get('http://www.baidu.com')
driver.page_source
lxml
#可以用pip安装
pip install lxml
#也可以下载下载 https://pypi.org/project/lxml/
import lxml
beautifulsoup4
#安装beautifulsoup4
pip3 install beautifulsoup4
#bs4是beautifulsoup4的其中一个包
from bs4 import BeautifulSoup
soup = BeautifulSoup('<html></html>','lxml')
pyquery
#pyquery相关文档 https://pythonhosted.org/pyquery/
#安装pyquery
pip3 install pyquery
from pyquery import PyQuery as pq
doc = pq('<html></html>')
doc = pq('<html>hello</html>')
result = doc('html').text()
result
'hello'
pymysql
pip3 install pymysql
import pymysql
conn = pymysql.connect(host='localhost',user='root',password='',port=3306,db='hank')
cursor = conn.cursor()
cursor.execute('select * from hank')
cursor.fetchone()
(1, 'hank', 'men', 18, '15019788915')
pymongo
pip3 install pymongodb
import pymongo
client = pymongo.MongoClient('localhost')
db = client['newtestdb']
db['table'].insert(('name':'Bob'))
db['table'].find_one(('name':'Bob'))
flask
#参考文档 http://docs.jinkan.org/docs/flask/
pip3 install flask
django
pip3 install django
import django
jupyter
pip3 install jupyter