python第三方庫requests,pymongo,bs4等用法總結html
requests; 請求網站,網頁
importrequests
help(requests
r = requests.get('https://www.baidu.com')python
pymongo ; 鏈接數據庫
數據庫 : iaaf
use iaaf
show tables ------- athletes
db.athletes.find()
pymongo ; db = pymongo.MongoClient().iaaf
for i in db.athletes.find():
print i數據庫
bs4 ; from bs4 import BeautifulSoup 解析頁面
html = r.content
soup = BeautifulSoup(html, 'html.parser')
type(soup)
l=soup.find_all("a")for i in l:
print i.text
print i.get("href") ide