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

remove 'www*.' prefix when parsing allowed_domains #27

Merged
merged 8 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
("https://example.com", "example.com"),
("https://www.example.com", "example.com"),
("https://www2.example.com", "example.com"),
BurnzZ marked this conversation as resolved.
Show resolved Hide resolved
("https://prefixwww.example.com", "prefixwww.example.com"),
("https://wwworld.example.com", "wwworld.example.com"),
("https://my.wwworld-example.com", "my.wwworld-example.com"),
("https://wwwow.com", "wwwow.com"),
("https://wowww.com", "wowww.com"),
("https://awww.com", "awww.com"),
)


Expand Down
2 changes: 1 addition & 1 deletion zyte_spider_templates/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@


def get_domain(url: str) -> str:
return re.sub(r"www.*?\.", "", parse_url(url).netloc)
return re.sub(r"^(www)\d?\.", "", parse_url(url).netloc)
BurnzZ marked this conversation as resolved.
Show resolved Hide resolved
Loading