feat(utils): add discoverValidSitemaps utility#3339
Merged
Conversation
barjin
reviewed
Jan 16, 2026
Member
barjin
left a comment
There was a problem hiding this comment.
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') |
Member
There was a problem hiding this comment.
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. |
Member
There was a problem hiding this comment.
nit: this doesn't mention sitemap.txt
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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), andurlExistsis 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.