Ask YC: Any ideas about intelligent crawlers :)
I'm thinking of creating an intelligent crawler in Python. I have a project with a friend where we'd like to crawl a few specific car-related websites, grab some of the info and look for new entries. I am wondering if there is any existing technology out there where a crawler is sent to a site and either trained (visually?) or which can understand repeating information like tables that we could use to create a proof of concept. I'd appreciate any critique of my ideas which is:
1. create a visual tool - probably windows/mac based which uses the browser to navigate a site and to highlight elements that we would like to capture, such as car name, description, price. This would also have to be able to automatically/manually work out repeating elements
2. this tool would create some kind of file (xml?) which would then be used by the main crawler to understand how to navigate the site
3. The crawler, which we'd write in python would visit the site every week to look for new information
Am I going about this the right way or does anyone have any ideas
One point, we would seek permission from the sites before crawling - it would be to their benefit as we're looking to push people their way.
Appreciate any thoughts anyone might have
All the best
John
31 comments
[ 6.5 ms ] story [ 104 ms ] threadIt is designed to scale and do mapreduce kind of parallel processing. I would strongly recommend you to take a look before writing your own.
http://lucene.apache.org/nutch/
At least in Germany, there exists a few solutions which do exactly that. If a person puts his car on sale (a bargain) on one of the car related websites, he get's the first call in about 20 seconds from someone using these programs.
This visual tool is basically what a company called onDisplay was doing back in 1999, before they were bought by consulting firm Vignette for an obscene amount of money. But scraping against the html structure is a losing battle.
A better approach is to use clues in the information itself to guess its content: something with a "$" is a price. Something containing "toyota" is probably a name, "blue" a color, more than 20 words containing "good", "v8" is a description, etc. That way your scraper is resistant to structure changes.
All that is separate from the problem of a crawler. It takes a long time and a lot of effort to convince content sites that what you are doing is a) helpful to them and b) something they should not be doing themselves.
It's like jumping on stage with the band and starting to play. You better be really good and friendly and prepared to get the crap beaten out of you.
Anybody remember this?
So i guess in theory you could write a frontend (firefox extension?) where you could highlight / select a screen area (webdeveloper already does this), then pass it's DOM information (i.e. #body table tr td#username ) to your backend, which would then scrape that field(s) from any applicable site pages.
This of course assumes that 1) The website(s) are well formed enough for your parser and 2) Well programmed enough that the same info is in the same place in the DOM tree, and preferably ID'd, which are pretty HUGE assumptions, but could be worked around if you were determined enough.
Not sure if this is what you're looking for, and it seems a bit circuitous, but it's a plausible idea anyway.
1. Use an html parsing library. Beautiful soup (python) or hpricot (ruby) are good building blocks.
2. Practice manually building parsers for a few sites, then see if it leads you to any insights about how to generalize the process.
3. Ignore everything else until you do 2. Just use wget as your crawler. Skip the visual interface for now; just parsing arbitrary pages is a hard enough problem to bite off.
http://tagtheplanet.net
They seem to be attempting an intelligent crawler as well.
http://mechanize.rubyforge.org/mechanize/
might be worth a look http://www.crummy.com/software/BeautifulSoup/
Any takers?
* automatic wrapper generation
* information extraction
* removing noisy information from Web pages
* template detection
* wrapper induction
"Wrapper" is a fancy computer-science term for "scraper."
I wrote some Python code that does this -- given X sample documents, detect the differences between them and automatically create a scraper tailored to those documents. I released the first version open source -- it's called templatemaker: http://code.google.com/p/templatemaker/ .
But that version of templatemaker is quite brittle, because it was designed to work on plain text as much as on HTML. I've since written an HTML-aware version of templatemaker that is really frikkin' awesome (if I may say!) and beats the pants off the old one. I don't know if I'm going to open-source it, as it's quite valuable to my own startup.
Hope this helps!
If its OK I'd like to let people know about my experiences. Oh, if anyone is interested in collaborating or just sharing ideas then I'd be happy to do likewise
All the best
Feel free to ask me more questions by email. I spend a fair bit of time thinking about html parsers.
As far as I understand, they are very close to what you are trying to do, so study them carefully as a competitor.
http://wwwsearch.sourceforge.net/mechanize/
And if you need to do complicated html parsing in combination with that:
http://www.crummy.com/software/BeautifulSoup/
From there, it's cake.
One thing that I would point out about the script you intend to write is that it requires an awful lot of maintenance (when sites change layout) and is frequently not very reusable. One solution that I tried is Mozenda (http://www.mozenda.com). The have all the stuff you're looking for (i.e. visual, browser-based tool, writing to XML) but also have error handling and notifications, so that if an agent breaks you'll know and be able to fix things inside the visual tool.