網頁爬蟲 靜態網頁《一》

2021-08-10 08:24:42 字數 714 閱讀 8905

一、通過jsoup請求獲取 網頁審查元素。

eg:request_path = "";

document doc = jsoup.connect(request_path).get();

二、檢視需要扣取資料的標籤,通過日誌輸出 doc的body。

eg:log.v(tag, "body :"+ doc.body());

三、檢視列印的日誌,找到需要的資料的節點。

可以看到其中的需要的主體本在在article_c節點中。

四、通過article_c節點 獲取到內容。

eg: 

elements allelements = doc.getelementsbyclass("article_c");

五、通過獲取的元素 讀取元素中的文字。

eg:int size = allelements.size();

log.v(tag, "size" + size);

string reslut = "";

if(size> 0 )

final string finalreslut = reslut;

runonuithread(new runnable()

});}相關的jar包:

做除錯用的原始碼,僅供參考:

靜態網頁爬蟲

我們通過 from bs4 import beautifulsoup 語句匯入 beautifulsoup,然後使用 beautifulsoup res.text,html.parser 語句將網頁源 的字串形式解析成了 beautifulsoup 物件。建立 beautifulsoup 物件時需要...

網頁爬蟲php,php網頁爬蟲

網頁爬蟲 最簡單的使用,屬性都採用預設值 curl curl init output curl exec curl curl close curl echo output 稍微複雜一點的,對頁面進行操作 curl curl init curl setopt curl,curlopt url,可以動態...

靜態網頁的爬蟲嘗試

去年寫的乙個簡單爬蟲,爬去全書網的盜墓筆記的部分章節,還是比較簡單的,但是現在看來還有很多小問題沒處理 鑑於只是第一次嘗試,保留下 以後看看回想思路比較合適,就不再去完善 了。import requests from bs4 import beautifulsoup class download o...