Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom link parser #458

Merged
merged 11 commits into from Jan 2, 2024
Merged

Conversation

Velka-DEV
Copy link
Contributor

Feature Overview

Purpose

This update addresses the current limitation where only <a href="..."> links are discoverable. Previously, there was no support for parsing elements like sitemaps and iframes.

Modifications

  • The LinkAdder class has been refashioned into the LinkUrlParser, now implementing the UrlParser interface.
  • Introduced a new SitemapUrlParser capable of parsing <loc> nodes within sitemaps.
  • The LinkUrlParser retains its original functionality and implementation, mirroring the erstwhile LinkAdder.
  • Added a new method to the Crawler class: public function setUrlParserClass(string $urlParserClass): self. This method allows for the dynamic assignment of the URL parser class.

Testing

  • Added new unit tests in the SitemapUrlParserTest file to validate the functionality of the SitemapUrlParser.

@freekmurze
Copy link
Member

Very nice! Could you also document how to crawl a sitemap using the new functionality? A clear example will be helpful for most users 👍

@Velka-DEV
Copy link
Contributor Author

Very nice! Could you also document how to crawl a sitemap using the new functionality? A clear example will be helpful for most users 👍

I've added a quick guide on using SitemapUrlParser for sitemap crawling in the docs. I also added some tests for sitemap indexes.

Also, Happy New Year 🎉 !

@freekmurze
Copy link
Member

🥳 Thanks, happy new year to you too!

@freekmurze freekmurze merged commit f4958b4 into spatie:main Jan 2, 2024
6 checks passed
@freekmurze
Copy link
Member

Thanks!

@Velka-DEV Velka-DEV deleted the feat/custom-link-adder branch January 2, 2024 13:14
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.

None yet

2 participants