Skip to content

feat(utils): add discoverValidSitemaps utility#3339

Merged
foxt451 merged 6 commits intomasterfrom
feat/discover-valid-sitemaps
Jan 19, 2026
Merged

feat(utils): add discoverValidSitemaps utility#3339
foxt451 merged 6 commits intomasterfrom
feat/discover-valid-sitemaps

Conversation

@foxt451
Copy link
Copy Markdown
Collaborator

@foxt451 foxt451 commented Jan 15, 2026

Related to apify/actor-scraper#220. 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
Copy Markdown
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:

Comment thread packages/utils/test/sitemap.test.ts Outdated
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
Copy Markdown
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).

Comment thread packages/utils/src/internals/sitemap.ts Outdated

/**
* 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
Copy Markdown
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
@nicklamonov nicklamonov added the t-tooling Issues with this label are in the ownership of the tooling team. label Jan 19, 2026
@foxt451 foxt451 merged commit 29f52ed into master Jan 19, 2026
9 checks passed
@foxt451 foxt451 deleted the feat/discover-valid-sitemaps branch January 19, 2026 13:46
barjin pushed a commit that referenced this pull request Feb 6, 2026
Related to https://github.com/apify/apify-sdk-js/issues/486. I'm
[developing generic sitemap
scraper](apify/actor-scraper#205) 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.
barjin added a commit that referenced this pull request Feb 6, 2026
Rebases #3339 and #3370 on top of `v4` and adds `HttpClient` support for
discoverValidSitemaps.

Related to the discussion under
apify/actor-scraper#214

---------

Co-authored-by: Sviatozar Petrenko <svpetrenko123@gmail.com>
janbuchar pushed a commit that referenced this pull request Mar 5, 2026
Rebases #3339 and #3370 on top of `v4` and adds `HttpClient` support for
discoverValidSitemaps.

Related to the discussion under
apify/actor-scraper#214

---------

Co-authored-by: Sviatozar Petrenko <svpetrenko123@gmail.com>
B4nan pushed a commit that referenced this pull request Mar 16, 2026
Rebases #3339 and #3370 on top of `v4` and adds `HttpClient` support for
discoverValidSitemaps.

Related to the discussion under
apify/actor-scraper#214

---------

Co-authored-by: Sviatozar Petrenko <svpetrenko123@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants