A simple bookmarklet that lets you click any element in a page and returns the smallest unique (and reliable) selector it can find for that element.
A simple bookmarklet that lets you click any element in a page and returns the smallest unique (and reliable) selector it can find for that element.
Licensed under the WTFPL.
**Usecase:** Figuring out a CSS-style selector for screenscraping.
**Usecase:** Figuring out a CSS-style selector for screenscraping.
**How to use the selector:** Use your favourite screenscraping library with CSS selector support. If you are using BeautifulSoup, you'll need to use my [patched version](https://github.com/joepie91/beautifulsoup) to have support for :nth-of-type() pseudoselectors as returned by ScraperScript.
**How to use the selector:** Use your favourite screenscraping library with CSS selector support. If you are using BeautifulSoup, you'll need to use my [patched version](https://github.com/joepie91/beautifulsoup) to have support for :nth-of-type() pseudoselectors as returned by ScraperScript.
Extremely experimental. <strong>Drag</strong> the following bookmarklet to your bookmark bar, and click it whenever you want to scrape a page.
Extremely experimental. <strong>Drag</strong> the following bookmarklet to your bookmark bar, and click it whenever you want to scrape a page.
It'll let you click any element in the page, and you'll get its unique selector.
It'll let you click any element in the page, and you'll get its unique selector.
</p>
</p>
<p>
<aclass="bookmarklet"href="javascript:(function(){_scraper_script=document.createElement('SCRIPT');_scraper_script.type='text/javascript';_scraper_script.src='http://cryto.net/scraperscript/scraperscript.js?x='+(Math.random());document.getElementsByTagName('head')[0].appendChild(_scraper_script);})();">Help me scrape!</a>
</p>
<p>
<p>
ScraperScript will block input to the page while it's active. To get control over your input again, simply close the ScraperScript bar using
ScraperScript will block input to the page while it's active. To get control over your input again, simply close the ScraperScript bar using
the X in the top right corner.
the X in the top right corner.
@ -15,7 +36,7 @@
and a link to the page you are trying to work with.
and a link to the page you are trying to work with.
</p>
</p>
<p>
<p>
<ahref="javascript:(function(){_scraper_script=document.createElement('SCRIPT');_scraper_script.type='text/javascript';_scraper_script.src='http://cryto.net/scraperscript/scraperscript.js?x='+(Math.random());document.getElementsByTagName('head')[0].appendChild(_scraper_script);})();">Help me scrape!</a>
There's also a <ahref="http://github.com/joepie91/scraperscript">repository for this stuff on GitHub</a>.