Skip to content

Conversation

@foxt451
Copy link
Collaborator

@foxt451 foxt451 commented Jan 15, 2026

Related to apify/apify-sdk-js#486. I'm developing generic sitemap scraper and it's going to share a big utility function (main chunk of logic) with wcc - discoverValidSitemaps. I've asked @barjin if I could factor it out and he told this util could fit into crawlee. It's mainly copied from wcc, but to keep the dependencies unchanged, it's using got-scraping to check for url existence instead of impit (I think it doesn't matter for sitemaps), and urlExists is inlined (until we don't add http client to these utils in v4 as @barjin told me). It's also turned into an async generator. Let me know if you see a better place for this util.

@foxt451 foxt451 marked this pull request as ready for review January 16, 2026 10:31
@foxt451 foxt451 requested a review from B4nan January 16, 2026 10:31
Copy link
Member

@barjin barjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm @foxt451 , thank you!

I'll let @janbuchar have a second look as the original author of this, but if it's a direct port from WCC, I think we can merge safely.

I have just these nits:

it('extracts sitemap from robots.txt', async () => {
nock('http://sitemap-discovery.com')
.get('/robots.txt')
.reply(200, 'Sitemap: http://sitemap-discovery.com/sitemap.xml')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change this so the robots.txt-referenced sitemap is not the well-known /sitemap.xml? This example passes even if robots.txt is missing (see test below).


/**
* Given a list of URLs, discover related sitemap files for these domains by checking the `robots.txt` file,
* the default `sitemap.xml` file and the URLs themselves.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this doesn't mention sitemap.txt

@foxt451 foxt451 requested review from janbuchar and removed request for B4nan January 16, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants