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: Automatically keep user-agent up to date with latest user-agent #3529

Open
wants to merge 1 commit into
base: mealie-next
Choose a base branch
from

Conversation

ndragon798
Copy link

What type of PR is this?

  • feature

What this PR does / why we need it: Removes the chore of updating the user-agent that we use instead automatically grabbing the most popular user-agent every day.

Which issue(s) this PR fixes:

Fixes #3524
Fixes #3457

Testing

Tested locally using docker-compose and using built in testing via task py:check

@ndragon798 ndragon798 changed the title Automatically keep user-agent up to date with latest user-agent feat: Automatically keep user-agent up to date with latest user-agent Apr 29, 2024
@ndragon798 ndragon798 marked this pull request as ready for review April 30, 2024 03:49
@hay-kot
Copy link
Collaborator

hay-kot commented May 1, 2024

I'm somewhat skeptical on adding this package into the project, especially since it hits an external API that we don't control.

Do you know what the fallback behavior is if the API isn't available?

@ndragon798
Copy link
Author

Yeah it will fall back to using a default user-agent defined in the package. I only know this because I updated the package before I added here.
https://github.com/Lennolium/simple-useragent/blob/249b6169749c71f8d5ff64e1d1f8347dd5ef47cb/src/simple_useragent/core.py#L42

_FALLBACK_DESKTOP = [
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
        "AppleWebKit/537.36 (KHTML, like Gecko) "
        "Chrome/110.0.0.0 Safari/537.36"
        ]

If it is able to reach out once then it will just fall back to the cached UA. The cache is updated every 24 hours.

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.

[SCRAPER] - www.colruyt.be/nl/lekker-koken recipe scraping returns failed to scrape url
2 participants