Mechanize Python and addheader method - how do I know the newest headers?

Deadly 提交于 2019-12-11 03:33:57

问题


Currently, I'm using mechanize like this:

        browser = mechanize.Browser()
        browser.set_handle_robots(False)
        browser.set_handle_equiv(False)
        browser.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]

However, operating systems and browsers get updated and I assume that this header: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1 should be updated as well.

Is there any template, method of building such header string? Where can I find the newest available values to build such header?


回答1:


Why do you need always the newest Useragent in your Fake-Header? Sites will not block you for using an older browser in most cases. So it would be sufficient to update from time to time (or not at all. Often its enough to add "Mozilla" to the front of the UA-string to get a response as a browser gets).

Another answer would be if you have a webserver running, get some random (non-bot) string from your http-logs.




回答2:


Visit http://www.useragentstring.com/pages/useragentstring.php for a list of current browser User-Agent strings. It can also automatically detect and explain your current browser's User-Agent details if you click on home.

You may also paste User-Agent strings to have them explained to you.

I had your same question in mind and stumbled upon that website just now. I got there by googling a User-Agent string, Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1'.

Happy coding!



来源:https://stackoverflow.com/questions/31636341/mechanize-python-and-addheader-method-how-do-i-know-the-newest-headers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!