Last time this question was asked on HN was in 2017 (<a href="https://news.ycombinator.com/item?id=15694118" rel="nofollow">https://news.ycombinator.com/item?id=15694118</a>), a lot has changed in the last 5 years in the world of web scraping (legal landscape, antibot unblockers, data type specific APIs, etc), so I thought it may be a good idea to refresh this question and see what are the most popular tools used by the HN community these days.
It's increasingly difficult these days to write scrapers that don't at some point need to execute JavaScript on a page - so you need to have a good browser automation tool on hand.<p>I'm really impressed by Playwright. It feels like it has learned all of the lessons from systems like Selenium that came before it - it's very well designed and easy to apply to problems.<p>I wrote my own CLI scraping tool on top of Playwright a few months ago, which has been a fun way to explore Playwright's capabilities: <a href="https://simonwillison.net/2022/Mar/14/scraping-web-pages-shot-scraper/" rel="nofollow">https://simonwillison.net/2022/Mar/14/scraping-web-pages-sho...</a>
Beautiful Soup gets the job done. I made several app by using it.<p>[1] <a href="https://github.com/altilunium/wistalk" rel="nofollow">https://github.com/altilunium/wistalk</a> (Scrap wikipedia to analyze user's activity)<p>[2] <a href="https://github.com/altilunium/psedex" rel="nofollow">https://github.com/altilunium/psedex</a> (Scrap goverment website to get list of all registered online services in Indonesia)<p>[3] <a href="https://github.com/altilunium/makalahIF" rel="nofollow">https://github.com/altilunium/makalahIF</a> (Scrap university lecturer's web page to get list of papers)<p>[4] <a href="https://github.com/altilunium/wi-page" rel="nofollow">https://github.com/altilunium/wi-page</a> (Scrap wikipedia to get most active contributors that contribute to a certain article)<p>[5] <a href="https://github.com/altilunium/arachnid" rel="nofollow">https://github.com/altilunium/arachnid</a> (Web scraper, optimized for wordpress and blogger)
In the world of SPA (single page applications), headless browser API is super helpful, playwright[1] and puppeteer[2] are very good choices.<p>[1] <a href="https://github.com/microsoft/playwright" rel="nofollow">https://github.com/microsoft/playwright</a><p>[2] <a href="https://github.com/puppeteer/puppeteer" rel="nofollow">https://github.com/puppeteer/puppeteer</a>
I built a tool called Browserflow (<a href="https://browserflow.app" rel="nofollow">https://browserflow.app</a>) that lets you automate any task in the browser, including scraping websites.<p>People love it for its ease-of-use because you can record actions via click-and-point rather than having to manually come up with CSS selectors. It intelligently handles lists, infinite scrolling, pagination, etc. and can run on both your desktop and in the cloud.<p>Grateful for how much love it received when it launched on HN 8 months ago: <a href="https://news.ycombinator.com/item?id=29254147" rel="nofollow">https://news.ycombinator.com/item?id=29254147</a><p>Try it out and let me know what you think!
Unpopular opinion, but Bash/Shell Scripting. Seriously, it's probably the fastest way to get things done. For fetching, use cURL. Want to extract particular markup? Use pup[1]. Want to process csv? Use cskit[2]. Or JSON? Use jq[3]. Want to use DB? Use psql. Once you get the hang of shell scripting, you can create simple scrapers by wiring up these utilities in a matter of minutes.<p>The only thing I wish was present was better support for RegExes. Bash and most unix tools don't support PCRE which can severely limiting. Plus, sometimes you want to process text as a whole vs line-by-line.<p>I would also recommend Python's sh[4] module if Shell scripting isn't your cup of tea. You get best of both worlds: faster dev work with Bash utils, and a saner syntax.<p>[1]: <a href="https://github.com/ericchiang/pup" rel="nofollow">https://github.com/ericchiang/pup</a><p>[2]: <a href="https://csvkit.readthedocs.io/en/latest/" rel="nofollow">https://csvkit.readthedocs.io/en/latest/</a><p>[3]: <a href="https://stedolan.github.io/jq/" rel="nofollow">https://stedolan.github.io/jq/</a><p>[4]: <a href="https://pypi.org/project/sh/" rel="nofollow">https://pypi.org/project/sh/</a>
curl-impersonate[1] is a curl fork that I maintain and which lets you fetch sites while impersonating a browser. Unfortunately, the practice of TLS and HTTP fingerprinting of web clients has become extremely common in the past ~1 year, which means a regular curl request will often return some JS challenge and not the real content. curl-impersonate helps with that.<p>[1] <a href="https://github.com/lwthiker/curl-impersonate" rel="nofollow">https://github.com/lwthiker/curl-impersonate</a>
We've built <a href="https://serpapi.com" rel="nofollow">https://serpapi.com</a><p>We've invented the industry what you referring as "data type specific APIs"; APIs that abstract away all proxies issues, captcha solvings, various layouts support, even scrapping-related legal issues, and much more to a clean JSON response every single call. It was a lot of work but our success rate and response times are now rivaling non-scraping commercial APIs: <a href="https://serpapi.com/status" rel="nofollow">https://serpapi.com/status</a><p>I think the next battle will be still legal despite all the wins in favor of scrapping public pages and common sense understanding this is the way to go. The EFF has been doing an amazing work in this world and we are proud to be a significant yearly contributor to the EFF.
As someone that has built and maintained a few scraper tools in my career: hand-written logic and patience because your scraper will break any time upstream changes their HTML. It's an infinite game of whack-a-mole outside your control.<p>Scrapers are very simple, effective and probably one of the least fun things to build.
My <a href="http://heliumhq.com" rel="nofollow">http://heliumhq.com</a> is open source and gives you a very simple Python API:<p><pre><code> from helium import *
start_chrome('github.com/login')
write('user', into='Username')
write('password', into='Password')
click('Sign in')
</code></pre>
To get started:<p><pre><code> pip install helium
</code></pre>
Also, you need to download the latest ChromeDriver and put it in your PATH.<p>Have fun :-)
Probably the best tool for scraping websites protected by services like cloudflare.
<a href="https://github.com/ultrafunkamsterdam/undetected-chromedriver" rel="nofollow">https://github.com/ultrafunkamsterdam/undetected-chromedrive...</a>
I've been using puppeteer as it's got a very established ecosystem. There are also puppeteer plugins that make it very powerful against captchas/detection/etc.<p>The worst thing about Puppeteer is chrome and it's bad memory management so I'm going to give playwright a spin soon.
estela is an elastic web scraping cluster running on Kubernetes. It provides mechanisms to deploy, run and scale web scraping spiders via a REST API and a web interface.<p>It is a modern alternative to the few OSS projects available for such needs, like scrapyd and gerapy. estela aims to help web scraping teams and individuals that are considering moving away from proprietary scraping clouds, or who are in the process of designing their on-premise scraping architecture, so as not to needlessly reinvent the wheel, and to benefit from the get-go from features such as built-in scalability and elasticity, among others.<p>estela has been recently published as OSS under the MIT license:<p><a href="https://github.com/bitmakerla/estela" rel="nofollow">https://github.com/bitmakerla/estela</a><p>More details about it can be found in the release blog post and the official documentation:<p><a href="https://bitmaker.la/blog/2022/06/24/estela-oss-release.html" rel="nofollow">https://bitmaker.la/blog/2022/06/24/estela-oss-release.html</a><p><a href="https://estela.bitmaker.la/docs/" rel="nofollow">https://estela.bitmaker.la/docs/</a><p>estela supports Scrapy spiders for the moment being, but additional frameworks/languages are on the roadmap.<p>All kinds of feedback and contributions are welcome!<p>Disclaimer: I'm part of the development team behind estela :-)
Quick plug for running scrapers in GitHub Actions and writing the results back to a repository - which gives you a free way to track changes to a scraped resource over time. I call this "Git scraping" - I've written a whole bunch of notes about this technique here: <a href="https://simonwillison.net/series/git-scraping/" rel="nofollow">https://simonwillison.net/series/git-scraping/</a>
The polite package using R is intended to be a friendly way of scraping content from the owner. "The three pillars of a polite session are seeking permission, taking slowly and never asking twice."<p><a href="https://github.com/dmi3kno/polite" rel="nofollow">https://github.com/dmi3kno/polite</a>
Python is my work horse, if I need to scrape something from a site that is relaxed about scraping (most are). I have my own library of helper functions I've built up over the years. In simple cases I just regex out what I need, if I need a full DOM then I use JSDOM/node.<p>For sites that are "difficult" I remote control a real browser, GUI and all. I don't use Chrome headless because if there's e.g. a captcha I want to be able to fill it in manually.
For Ruby I recommend Medusa Crawler gem.<p>[1] <a href="https://github.com/brutuscat/medusa-crawler" rel="nofollow">https://github.com/brutuscat/medusa-crawler</a><p>Which I maintain as a fork of the unmaintained Anemone gem.
I’m not sure about “best” but I’ve been using Colly (written in Go) and it’s been pretty slick. Haven’t run in to anything it can’t do.<p><a href="http://go-colly.org/" rel="nofollow">http://go-colly.org/</a>
I don’t think the landscape has changed much since then. However, from my experience you should do everything possible to avoid a headless browser for scraping. It’s in the region of 10-100x slower and significantly more resource intensive, even if you carefully block unwanted requests (images, css, video, ads).<p>Obviously sometimes you have to go that route.
I have used the Apify SDK (now <a href="https://crawlee.dev/" rel="nofollow">https://crawlee.dev/</a>) in the past and found it very useful.
If the content you need is static, I like using node + cheerio [0] as the selector syntax is quite powerful. If there is some javascript execution involved however, I will fall back to puppeteer.<p>[0] - <a href="https://cheerio.js.org/" rel="nofollow">https://cheerio.js.org/</a>
I wrote my own webscraper: <a href="https://videlibri.de/xidel.html" rel="nofollow">https://videlibri.de/xidel.html</a><p>The main purpose was to submit HTML forms. You just say in which input fields something should be written and then it does the other things (i.e. download the page, find all other fields and their default values, build a HTTP request from all of them and send that ).<p>The last 5 years, I spent updating the XPath implementation to XPath/XQuery 3.1. The W3C has put a lot new stuff in the new XPath versions like JSON support or higher order functions, for some reason they decided to turn XPath into a Turing-complete functional programming language.
I’ve got several years of experience of webscraping, mainly in python.
Scrapy is the first choice for “basic websites” while playwright is used then things get difficult.
I’m collecting my experience in using these tools in this “web scraping open knowledge project” on github (<a href="https://github.com/reanalytics-databoutique/webscraping-open-project" rel="nofollow">https://github.com/reanalytics-databoutique/webscraping-open...</a>) and on my substack (<a href="http://thewebscraping.club/" rel="nofollow">http://thewebscraping.club/</a>) for longer free content
I have had some luck running puppeteer in a nodejs app hosted at glitch.com. I spring for the (cheap) paid hosting and get several containers for dev/test/prod, web based ide. Obviously, this would only scale to a point. In my case I just need a single client automating interaction with a single site. If I really needed scale, I'd probably use one of the services listed elsewhere.<p>Of course, if you don't need a full javascript-enabled browser parse, consider alternatives first: simple HTTP requests, API, RSS, etc.
For simple scraping where the content is fairly static, or when performance is critical, I will use linkedom to process pages.<p><a href="https://github.com/WebReflection/linkedom" rel="nofollow">https://github.com/WebReflection/linkedom</a><p>When the content is complex or involves clicking, Playwright is probably the best tool for the job.<p><a href="https://github.com/microsoft/playwright" rel="nofollow">https://github.com/microsoft/playwright</a>
Has anybody created anything similar to Portia for scraping? I'd love to self host or pay a nominal fee to allow my team to create / adjust scrapers via a UI
Obviously scraping logic using puppeteer, but there are many other tooling aspects that are critical to bypass bot prevention.<p>one is signature / fingerprinting emulation. It helps to run the bot in a real browser and export the fingerprint (e.g. UA, canvass, geoloc etc) into JS object . Add noise to the data too.<p>Simulate residential IPs by routing through a residential proxy. If you run bots from cloud you will get blocked.
I’ve built a lot of tools utilizing web scraping most recently <a href="https://GitHub.com/Jawerty/myAlgorithm" rel="nofollow">https://GitHub.com/Jawerty/myAlgorithm</a> and <a href="https://metaheads.xyz" rel="nofollow">https://metaheads.xyz</a> I think the more control you have over the tools the better if you know your way around css selectors and selenium you can do anything web scraping. Selenium can seem hefty but there are plenty of ways to optimize for resource intensity; look up selenium grid. Overall, don’t be afraid of browser automation you can Always find a way to optimize. The real difficulty is freshness of html. This you can fix by being smart about time stamps and caching. If you have the same data you’re scraping consistently…don’t do that. Also if there’s a frontend in your application dependent on scraped data NEVER use your scraping routines as a direct feed, store data whenever you scrape.
i hate to be that guy, but “it depends”<p>scrapy is still king for me (scrapy.org). there are even packages to use headless browsers for those awful javascript heavy sites<p>however, APIs and RSS are still in play, and that does not require a heavy scraper. I am building vertical industry portals, and many of my data rollups consume APIs and structured XML/RSS feeds from social and other sites.
Many years ago I wrote a scraper-module for a scripting language that exposed a fake DOM to an embedded JS-engine, spidermonkey. The DOM was just an empty object graph, readable both from the scripting language and inside the JS context. The documents were parsed by libxml2 and the resulting DOMs were not identical to mozilla's, for example. But fast and efficient.<p>The purpose was to enable "live interactive" scraping of forms/js/ajax sites, with a web frontend controlling maybe 10 scrapers for each user. When that project fell through, I stopped maintaining it and the spidermonkey api has long since moved on.<p>It works for simple sites that don't require the DOM to actually do anything (for example triggering images to load with some magic url). But many simple DOM behaviours can be implemented.
It depends on what you are trying to accomplish, but I think a combination of Puppeteer and JSDOM or Cheerio should take you far. Where it gets complex is when you need to do things such as rotating IPs, but in my experience, that's only needed if you're engaging in a heavy scraping workload.<p>Puppeteer + JSDOM is what I used to build <a href="https://www.getscrape.com" rel="nofollow">https://www.getscrape.com</a>, which is a high-level web scraping API. Basically, you tell the API if you want links, images, texts, headings, numbers, etc; and the API gets all that stuff for you without the need to pass selectors or parsing instructions.<p>In case anyone here wants something straightforward. It works well to build generic scraping operations.
I'm working on a personal project that involves A LOT of scraping, and through several iterations I've gotten some stuff that works quite well. Here's a quick summary of what I've explored (both paid and free):<p>* Apify (<a href="https://apify.com/" rel="nofollow">https://apify.com/</a>) is a great, comprehensive system if you need to get fairly low-level. Everything is hosted there, they've got their own proxy service (or you can roll your own), and their open source framework (<a href="https://github.com/apify/crawlee" rel="nofollow">https://github.com/apify/crawlee</a>) is excellent.<p>* I've also experimented with running both their SDK (crawlee) and Playwright directly on Google Cloud Run, and that also works well and is an order-of-magnitude less expensive than running directly on their platform.<p>* Bright Data nee Luminati is excellent for cheap data center proxies ($0.65/GB pay as you go), but prices get several orders of magnitude more expensive if you need anything more thorough than data center proxies.<p>* For some direct API crawls that I do, all of the scraping stuff is unnecessary and I just ping the APIs directly.<p>* If the site you're scraping is using any sort of anti-bot protection, I've found that ScrapingBee (<a href="https://www.scrapingbee.com/" rel="nofollow">https://www.scrapingbee.com/</a>) is by far the easiest solution. I spent many many hours fighting anti-bot protection doing it myself with some combination of Bright Data, Apify and Playwright, and in the end I kinda stopped battling and just decided to let ScrapingBee deal with it for me. I may be lucky in that the sites I'm scraping don't really use JS heavily, so the plain vanilla, no-JS ScrapingBee service works almost all of the time for those. Otherwise it can get quite expensive if you need JS rendering, premium proxies, etc. But a big thumbs up to them for making it really easy.<p>Always looking for new techniques and tools, so I'll monitor this thread closely.
We’ve built a freemium cloud RPA software focused on web scraping and monitoring, called Browse AI.<p><a href="https://www.browse.ai" rel="nofollow">https://www.browse.ai</a><p>It lets you train a bot in 2 minutes. The bot will then open the site with rotating geolocated ip addresses, solve captchas, click on buttons and scroll and fill out forms, to get you the data you need.<p>It’s integrated with Google Sheets, Airtable, Zapier, and more.<p>We have a Google Sheets addon too which lets you run robots and get their results all in a spreadsheet.<p>We have close to 10,000 users with 1,000+ signing up every week these days. That made us raise a bit of funding from Zapier and others to be able to scale quicker and build the next version.
For a particular type of scraping, we wrote SSScraper on top of Colly and it works really well:<p><a href="https://github.com/gotripod/ssscraper/" rel="nofollow">https://github.com/gotripod/ssscraper/</a>
<i>* Shameless plug *</i>: our super-easy feed builder at New Sloth (formerly Feedity) - <a href="https://newsloth.com" rel="nofollow">https://newsloth.com</a> combines a scraper and data transformer, which helps create custom RSS feeds for any public webpage. Our API can auto-magically detect relevant articles in most cases. The platform includes an integrated feed reader and clusterer/deduplicator, specially aimed for knowledge workers with hundreds and thousands of feeds to monitor daily.
Not a full fledged scraper but IDS[1] has great heuristics to figure relevant content/information behind HTML code therefore lesser/no iterations needed in case frontend code changes.<p>Would be cool to reverse engineer it and probably plug it into some JS rendering testing solution (say Puppeteer, etc.)<p>[1] <a href="https://chrome.google.com/webstore/detail/instant-data-scraper/ofaokhiedipichpaobibbnahnkdoiiah" rel="nofollow">https://chrome.google.com/webstore/detail/instant-data-scrap...</a>
Normalize Rest calls so programmers don’t have to rely on webscrapers, selenium and other flaky methods of retrieving data.<p>Web scraping is fun, but in production it’s an absolute joke.
I am probably in the minority, but I try to outsource scraping whenever possible. It's too much grunt work: you have to constantly baby sit the crawlers that break because websites keep changing.<p>Personally, I use Indexed (<a href="https://www.indexedinc.com" rel="nofollow">https://www.indexedinc.com</a>) because they are technical and reliable, although there are many other providers out there..
Is there any form of markup / library that would allow me to access a file-tree similar to what show's up in the chrome "inspect" "sources" tab? I'm working on a system to extract m3u8 files from websites. Haven't found a good way to do this yet a few years since my last project that required scraping with a headless browser.
Have to appreciate the irony of someone's SEO spam submission (submitter works for a company selling scraping services) being SEO spammed in the comments...<p>>Thanks for the links. And I read too. I see a lot of useful stuff that I will use for my site <a href="https://los-angeles-plumbers.com/" rel="nofollow">https://los-angeles-plumbers.com/</a>
Scrapy's crawling and CSS/xpath selectors are fine. But I'm annoyed about the pipeline after that. Especially to get the data into a SQLite database. I wish cleaning up the data was a series of transformations on SQL tables instead of a bunch of work on Python models.
A good no-code solution is <a href="https://simplescraper.io" rel="nofollow">https://simplescraper.io</a>. Leans towards non-developers but there's an API too.
I’m biased since I’m an owner of a web scraping agency (<a href="https://webscrapingsolutions.co.uk/" rel="nofollow">https://webscrapingsolutions.co.uk/</a>). I was asking myself the same question in 2019.
You can use any programming language, but have settled on this tech-stack Python, Scrapy (<a href="https://github.com/scrapy/scrapy" rel="nofollow">https://github.com/scrapy/scrapy</a>), Redis, PostgreSQL. for the following reasons:<p>[1] Scrapy is a well-documented framework, so any Python programmer can start using it after 1 month of training. There are a lot of guides for beginners.<p>[2] Lots of features are already implemented and open-source, you won’t have to waste time & money on them.<p>[3] There is a strong community that can help with most of the questions (I don't think any other alternative has that).<p>[4] Scrapy developers are cheap. You will only need junior+ to middle level software engineers to pull out most of the projects. It’s not rocket since.<p>[5] Recruiting is easier: - there are hundreds of freelancers with relevant expertise - if you search on LinkedIn - there are hundreds of software developers that have worked with Scrapy in the past, and you don’t need that many - you can grow expertise in your own team quickly - developers are easily replaceable, even on larger projects - you can use the same developers on backend tasks.<p>[6] You don’t need a DevOps expertise in your web scraping team because Scrapy Cloud (<a href="https://www.zyte.com/scrapy-cloud/" rel="nofollow">https://www.zyte.com/scrapy-cloud/</a>) is good and cheap enough for 99% of the projects.<p>[7] If you decide to have your own infrastructure, you can use <a href="https://github.com/scrapy/scrapyd" rel="nofollow">https://github.com/scrapy/scrapyd</a>.<p>[8] The entire ecosystem is well-well-maintained and steadily growing. You can integrate a lot of 3-rd party services into your project within hours: proxies, captcha solving, headless browsers, HTML parsing APIs.<p>[9] It’s easy to integrate your own AI/ML models into the scraping workflow.<p>[10]. With some work, you can use Scrapy for distributed projects that are scraping thousands (millions) of domains. We are using <a href="https://github.com/rmax/scrapy-redis" rel="nofollow">https://github.com/rmax/scrapy-redis</a>.<p>[11] Commercial support is available. There are several companies that can develop you an entire project or take over an existing one - if you don’t have the time/don’t want to do it on your own.<p>We have built dozens of projects in multiple industries:<p>- news monitoring<p>- job aggregators<p>- real estate aggregators<p>- ecommerce (anything from 1 website, to monitoring prices on 100k+ domains)<p>- lead generation<p>- search engines in a specific niche (SEO, pdf files, ecommerce, chemical retail)<p>- macroeconomic research & indicators<p>- social media, NFT marketplaces, etc<p>So, most of the projects can be finished using these tools.
I've thought <a href="https://www.scrapingbee.com/" rel="nofollow">https://www.scrapingbee.com/</a> looked great, especially their auto rotation of IP addresses.
Try <a href="https://webscraping.ai/" rel="nofollow">https://webscraping.ai/</a> if you need rotating proxies and JS rendering
You can also use the common crawl dataset.<p><a href="https://commoncrawl.org/" rel="nofollow">https://commoncrawl.org/</a>
it depends. for no-code solution, please check [powerpage-web-crawler](<a href="https://github.com/casualwriter/powerpage-web-crawler" rel="nofollow">https://github.com/casualwriter/powerpage-web-crawler</a>) for crawling blog/posts.
if you are tech enough to find the query-selector of the elements, here is a great tool.<p>Great things is, it have support for Zapier, webhooks and API access too.!<p><a href="https://browserbird.com" rel="nofollow">https://browserbird.com</a>
if you are looking for pre-made tools and dont want to write any code, check our <a href="https://webautomation.io" rel="nofollow">https://webautomation.io</a>