路飛學城—python爬蟲實戰密訓-—第1章
阿新 • • 發佈:2018-07-05
param 新聞 之前 code col 程序 find ... 定義
一.本節學習體會,心得:
- 因為之前只是看了Python基礎的內容,以為爬蟲的內容自己會看不懂,但是視頻裏的老師講得很好,生動易懂。
- 學習編程,就要親自練習,看視頻覺得懂了,自己親自做起來,就有了一點阻礙。
二.知識點總結:
- 爬蟲定義:通過程序去獲取網頁上自己想要的數據,也就是自動抓取數據。爬蟲通過分析html代碼,從中獲取文本,圖片,視頻.....
- 發送請求用http request,在這個歌之前要安裝requests 和bs4 模塊,在控制臺窗口裏用 pip install 模塊名 來進行安裝。
- request請求中包含,請求頭,請求體,method:url:params:data:
- 爬取汽車之家新聞練習
import requests from bs4 import BeautifulSoup ret = requests.get(url="https://www.autohome.com.cn/news/") ret.encoding = ret.apparent_encoding # print(ret.text) soup = BeautifulSoup(ret.text,‘html.parser‘) div = soup.find(name=‘div‘,id=‘auto-channel-lazyload-article‘) li_list
路飛學城—python爬蟲實戰密訓-—第1章