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

2

2

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?

Berwickupontweed answered 26/7, 2015 at 11:15 Comment(0)
R
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.

Rickrickard answered 26/7, 2015 at 16:38 Comment(0)
D
0

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!

Deannedeans answered 18/11, 2015 at 10:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.