User Agent addition - #5
Conversation
some security plugins are blocking requests without user-agent. in this change I added a user-agent so it is possible to request
MickaelWalter
left a comment
There was a problem hiding this comment.
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.
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.
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.
Take your time.
I haven't updated it for 9 months anyway :D
There was a problem hiding this comment.
@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