-
Notifications
You must be signed in to change notification settings - Fork 26
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
User Agent addition #5
base: master
Are you sure you want to change the base?
Conversation
some security plugins are blocking requests without user-agent. in this change I added a user-agent so it is possible to request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi!
Thank you for your contribution. I was thinking about letting the User Agent choice but never ran into the use case. Would it be possible to add a new argument to the Argument Parser, then just pass the user choice to a RequestSession
setter or directly as a RequestSession.__init__
argument? That would at least let the user choose which User Agent they want.
I foresee something like this:
--user-agent 1
: allows to get a User Agent from a list of hardcoded common User Agents
--list-ua
: allows to list the available hardcoded User Agents
--user-agent "User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36"
: allows to manually define any User Agent.
What do you think about this?
headers = { | ||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to avoid hardcoded User Agent and rather use a flag on the command line? (e.g. --ua or --user-agent flag). It would need to add the argument in the ArgumentParser, and add a setter or a parameter to RequestSession.init. Shouldn't be too hard. Maybe it would be also useful to add a little set of common User Agents in the code and let the user choose in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm working on the changes, i have python as an adventure since i always programmed PHP haha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take your time.
I haven't updated it for 9 months anyway :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MickaelWalter I hard-coded a fix onto my copy a while back, but I agree that a multi-faceted approach (with the three flags you mentioned) works best. Also wanted to say this tool has been incredibly useful in my work. Thanks for building it.
some security plugins are blocking requests without user-agent.
in this change I added a user-agent so it is possible to request