Python 網路爬蟲入門詳解!!

2021-10-24 19:00:56 字數 559 閱讀 6411

說明:並非是最優**,但程式完全正確!因為此時作者也處在學習階段!

(1)抓取網頁

(2)採集資料

(3)資料處理

(4)提供檢索服務

http協議和抓包工具

http服務埠是80埠

https服務埠號是443埠,https協議實在http協議上加入了ssl層,進行了加密

url(統一資源定位符)

組成部分:scheme://host:port/path/?query-string=*** #anchor

乙個url有以下幾部分組成:

scheme:代表的是訪問協議,一般為http或https以及ftp等

host:主機名,網域名稱。比如www.baidu.com

port:埠號,預設為80埠

path:查詢路徑

query-string:查詢字串(在?後面的內容)

anchor:錨點,前端用來做頁面定位的(在#後面的內容)

持續不斷地更新!!

python網路爬蟲入門

from urllib import request fp request.urlopen content fp.read fp.close 這裡需要使用可以從html或者xml檔案中提取資料的python庫,beautiful soup 安裝該庫 pip3 install beautifulsou...

Python網路爬蟲入門(四)

beautifulsoup庫 from bs4 import beautifulsoup html soup beautifulsoup html,lxml 列印所有的tr標籤 trs soup.find all tr for tr in trs print tr 獲取第二個tr標籤 tr soup...

python網路爬蟲入門(二)

一 python爬取10頁250條資料中的所有 書單 模組案例方法一 encoding utf 8 import requests from bs4 import beautifulsoup i 25 while i 225 i i 25 c str i resp requests.get c so...