News for hackers. Stuff that matters.
Re:Web scraping with GPT-4o: powerful but expensive by namukang on Tuesday September 03, 2024 @04:18AM (#41432554)
For structured content (e.g. lists of items, simple tables), you really don’t need LLMs.

I recently built a web scraper to automatically work on any website [0] and built the initial version using AI, but I found that using heuristics based on element attributes and positioning ended up being faster, cheaper, and more accurate (no hallucinations!).

For most websites, the non-AI approach works incredibly well so I’d make sure AI is really necessary (e.g. data is unstructured, need to derive or format the output based on the page data) before incorporating it.

[0] https://easyscraper.com

Re:Web scraping with GPT-4o: powerful but expensive by sebstefan on Tuesday September 03, 2024 @07:54AM (#41434003)
The LLM is resistant to website updates that would break normal scraping

If you do like the author did and ask it to generate xPaths, you can use it once, use the xPaths it generated for regular scraping, then once it breaks fall back to the LLM to update the xPaths and fall back one more time to alerting a human if the data doesn't start flowing again, or if something breaks further down the pipeline because the data is in an unexpected format.

Re:Web scraping with GPT-4o: powerful but expensive by is_true on Tuesday September 03, 2024 @08:49AM (#41434458)
Xpath can be based on content, not only positions
Re:Web scraping with GPT-4o: powerful but expensive by sebstefan on Wednesday September 04, 2024 @02:40AM (#41442555)
I normally use query selectors for scraping, I'm not sure why the author doesn't
Re:Web scraping with GPT-4o: powerful but expensive by melenaboija on Tuesday September 03, 2024 @08:49AM (#41434460)
Unless the update is splitting cells.

> Turns out, a simple table from Wikipedia (Human development index) breaks the model because rows with repeated values are merged

Re:Web scraping with GPT-4o: powerful but expensive by sebstefan on Tuesday September 03, 2024 @09:58AM (#41435020)
Nah, still correct :-) that would break the regular scraping as well

>The LLM is resistant to website updates that would break normal scraping

Re:Web scraping with GPT-4o: powerful but expensive by trog on Tuesday September 03, 2024 @06:28PM (#41439968)
This is absolutely true, but it does have to be weighed against the performance benefits of something that doesn't require invoking an LLM to operate.

If the cost of updating some xPath things every now and then is relatively low - which I guess means "your target site is not actively & deliberately obfuscating their website specifically to stop people scraping it"), running a basic xPath scraper would be maybe multiple orders of magnitude more efficient.

Using LLMs to monitor the changes and generate new xPaths is an awesome idea though - it takes the expensive part of the process and (hopefully) automates it away, so you get the benefits of both worlds.

Re:Web scraping with GPT-4o: powerful but expensive by poulpy123 on Tuesday September 03, 2024 @08:05AM (#41434104)
yours is the first one see that allows to scrape by selecting directly what to scrape. I always wondered why there was no tool doing that.
Re:Web scraping with GPT-4o: powerful but expensive by sebstefan on Tuesday September 03, 2024 @10:01AM (#41435053)
I've seen another website like this that had this feature on hackernews but it was from a retrospective. These websites have the nasty habit of ceasing operations
Re:Web scraping with GPT-4o: powerful but expensive by echelon on Tuesday September 03, 2024 @01:55PM (#41437338)
It needs to be a library.