天天看點

怎麼快速找到html結構,谷歌浏覽器插件SelectorGadget 快速找到html結構資訊的插件友善爬取...

怎麼快速找到html結構,谷歌浏覽器插件SelectorGadget 快速找到html結構資訊的插件友善爬取...

SelectorGadget是一個開源的Chrome擴充,能夠為複雜網站的元素生成CSS選擇器,這款神器有助于我們快速找到html的結構資訊。特别是在于需要做采集工作,那麼它是一個提升效率的工具。

①打開需要工作的網站,例如當當網的圖書排行榜:“http://bang.dangdang.com/books/bestsellers/01.00.00.00.00.00-recent7-0-0-1-1”

②比如我們想獲得書名的html結構資訊,此時我們隻需要先點選谷歌浏覽器上圖示,然後再在書名的點選,如圖一所示:

怎麼快速找到html結構,谷歌浏覽器插件SelectorGadget 快速找到html結構資訊的插件友善爬取...

在上圖中,我們發現很多地方都變成高亮(即黃色部分),但是我們隻想獲得書名資訊,是以我們需要去除多餘的資訊,此刻隻需在不需要的部分再次點選,即可去掉選中部分。例如,我們上圖的基礎上再點選圖上上面的“往年”的“2013年”,即點選下圖的“2013”年

怎麼快速找到html結構,谷歌浏覽器插件SelectorGadget 快速找到html結構資訊的插件友善爬取...

點選後就會發現現在網頁中高亮部分(即黃色部分)就隻有“書名”資訊,如下圖所示:

怎麼快速找到html結構,谷歌浏覽器插件SelectorGadget 快速找到html結構資訊的插件友善爬取...

這時候我們再檢視谷歌浏覽器右下角就可以看到結構标簽,即.name a

怎麼快速找到html結構,谷歌浏覽器插件SelectorGadget 快速找到html結構資訊的插件友善爬取...

點選圖檔上面的“clear(20)”即可清除自己現在選取的資訊,重新進行選擇~

此項技能可以與R語言中的rvest包結合使用去爬取網頁。

使用方法來自:大耳朵兔兔Easy, powerful CSS Selector generation.

Selector Gadget is an open source Chrome Extension that makes CSS selector generation and discovery on complicated sites a breeze.

After having installed the extension, go to any page and launch it. A box will open in the bottom right of the website. Click on a page element that you would like your selector to match (it will turn green). SelectorGadget will then generate a minimal CSS selector for that element, and will highlight (yellow) everything that is matched by the selector. Now click on a highlighted element to remove it from the selector (red), or click on an unhighlighted element to add it to the selector. Through this process of selection and rejection, SelectorGadget helps you come up with the perfect CSS selector for your needs.

SelectorGadget v1.1.1

上次更新日期:2020年5月18日

點選進入下載下傳頁