Python: Selenium Crawler

From OnnoWiki
Revision as of 04:41, 31 January 2017 by Onnowpurbo (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

WARNING masih belum jalan / saya tidak bisa install / pakainya dengan benar


Quickstart

pip install -e git+https://github.com/cmwslw/selenium-crawler.git#egg=selenium-crawler
from seleniumcrawler import handle_url
print handle_url('https://news.ycombinator.com/item?id=5626377')

This will open up a browser window, 'click' on the main link, and load the article. It will print the following:

{
    'url': 'http://googleblog.blogspot.com/2013/04/google-now-on-your-iphone-and-ipad-with.html',
    'source': Template:HTMLSOURCE,
    'handler': 'hnews'
}

Where Template:HTMLSOURCE is the actual HTML of the article.


Referensi