爬蟲必備XPath工具介紹
爬蟲 x 自由時報爬蟲實戰
爬蟲2 x 自由時報網站結構分析
爬蟲3 x XPath 工具介紹
爬蟲4 x Scrapy 框架介紹及實作
爬蟲5 x Scrapy 自由時報新聞實戰
爬蟲6 x Scrapy 自由時報新聞實戰2
XPath基於XML的樹狀結構,提供在資料結構樹中找尋節點的能力。 [1]
如圖1可知,我們透過//ul[@id=”newslistul”]//li來檢索id為newslistul的ul中底下的所有li節點,藉此我們可取得我們需要的所有區塊(block)
XPath的介紹可參考註1,關於在XPath中的//(double slash)可參考註2
如圖2所框選的紅色區塊,我們這邊使用到的是Chrome extension
Extract, edit, and evaluate XPath queries with ease.
XPath Helper makes it easy to extract, edit, and evaluate XPath queries on any webpage. [3]
簡單來說,XPath Helper幫助視覺化我們的XPath Query語句,在Debug和驗證階段中非常的好用
XPath的介紹大概就到這邊拉,有興趣想要深入的人再自己去找尋相關資源囉~