Lurker News
My partner usually writes substack posts which I then mirror to our website’s blog section.

To automate this, I made a simple tool to scrape the post and clean it so that I can drop it to our blog easily. This might be useful to others as well.
Oh and ofcourse you can instruct GPT to make any final edits :D

Comments (99) 41 threads

screye3 replies#
Converting websites to markdown comes with 3 distinct problems:

1. Throughly scraping the content of page (high recall)
2. Dropping all the ads/auxilliary content (high precision)
3. And getting the correct layout/section types (formatting)
For #2 and #3 - Trafilatura, Newspaper4k and python-readability based solutions work best out of the box. For #1, any scraping service + selenium is going to do a great job.
Could you elaborate on what your tool does different or better? The area has been stagnant for a while. So curious to hear your learnings.

cchance#
Those are pretty damn cool i didnt know those even existed.
scary-size3 replies#
Thoroughly scraping is challenging, especially in an environment where you don’t have (or want) a JavaScript runtime.

For content extraction, I found the approach the Postlight library takes quite neat. It scores individual html nodes based on some heuristics (text length, link density, css classes). It the selects the nodes with the highest score. [1] I ported it to Swift for a personal read later app.
[1] https://github.com/postlight/parser

justech1 reply#
This is pretty cool. Care to share your Swift port?
scary-size#
Not planning to. It’s my first Swift/iOS project. I neither want to polish it nor maintain it publicly. Happy to share it privately, email is in the bio. I’m planning on a blog post describing the general approach though!
rismay#
Care to share the Swift port?
msp261 reply#
Thanks for the links I had no idea those existed.

For my article web scraper (wip) the current steps are:
- Navigate with playwright + adblocker
- Run mozilla's readability on the page
- LLM checks readability output
If check failed
- Trim whole page HTML context
- Convert to markdown with pandoc
- LLM extracts from markdown

asadalt#
you would still need to run. For js based websites.
msp26#
I still wanted the browser for UBlock Origin and handling sites with heavy JS. I was using the standalone Readability script already but today I ended up dropping it for Trafilatura. It works a lot better.

The inefficiency of using a browser rather than just taking the html doesn't really matter because the limiting factor is the LLM here.
And yes the LLM is essential for getting clean data. None of the existing methods are flexible enough for all cases even if people say "you don't need AI to do this".

selfie3 replies#
Vercel!! Watch out for you bill now this is being hugged. Hopefully you are not using like they pester you to do.
asadalt#
it has actually scaled pretty well and has been negligible cost-wise.

I didn’t have to do anything to handle HN traffic. Just a boilerplate nextjs app.

compootr#
it's pretty sad, they motivate you all throughout their docs to use it, when just a webp would work ok

it's literally that meme of the bus — the happy guy is you and vercel and the sad one is your wallet
(unless you need dynamic scaling and minification though)

aleksandern081 reply#
What’s the problem with ?
asadm#
Vercel charges for image optimizations/dynamic scaling. People get wrong perception that it should be a free service because the DX is so easy...
jot2 replies#
Great idea to offer image downloads and filtering with GPT!

I built a similar tool last year that doesn't have those features: https://url2text.com/
Apologies if the UI is slow - you can see some example output on the homepage.
The API it's built on is Urlbox's website screenshot API which performs far better when used directly. You can request markdown along with JS rendered HTML, metadata and screenshot all in one go: https://urlbox.com/extracting-text
You can even have it all saved directly to your S3-compatible storage: https://urlbox.com/s3
And/or delivered by webhook: https://urlbox.com/webhooks
I've been running over 1 million renders per month using Urlbox's markdown feature for a side project. It's so much better using markdown like this for embeddings and in prompts.
If you want to scrape whole websites like this you might also want to checkout this new tool by dctanner: https://usescraper.com/

jph001 reply#
Looks nice, but url2text doesn't seem to have an API, and urlbox doesn't seem to have an option to skip the screenshot if you only want the text. And for just the text, it looks to be really expensive.
jot#
Thanks!

Sorry it's not clearer but you can skip the screenshot in the Urlbox API if you want to with:

  curl -X POST \
    https://api.urlbox.io/v1/render/sync \
    -H 'Authorization: Bearer YOUR_URLBOX_SECRET' \
    -H 'Content-Type: application/json' \
    -d '
  {
    "url": "example.com",
    "format": "md"
  }
  '
Here's the result of that: https://renders.urlbox.io/urlbox1/renders/5799274d37a8b4e604...

Sorry the pricing isn't a good fit for you. Urlbox has been running for over 11 years. We're bootstrapped and profitable with a team of 3 (plus a few contractors). We're priced to be sustainable so our customers can depend on us in the long term. We automatically give volume discounts as your usage grows.

old_dev1 reply#
It looks like, if the website presents a cookie message, the tool just gets stuck on that and does not parse the actual content. As an example, I tried https://www.cnbc.com/ and all it created was a markdown of the cookie message and some legalese around it.
jot#
It's not easy working around things like that. But here's how it could work: https://url2text.com/u/wYVake

We were lucky to build this on a mature API that already solves loads of the edge cases around rendering different kinds of pages.

Load more comments