I want to create a urllib2 opener, so it would look like it is a mobile phone.
I don’t know what I should change or may be you know any existing library that will do the trik.
That’s what I have now:
cj=cookielib.CookieJar()
#Process Hadlers
opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
#install opener, now all the calls to urllib2.urlopen use this opener
urllib2.install_opener(opener)
opener.addheaders=[
('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13'),
#('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'),
('Accept-Language', 'en-gb,en;q=0.5'),
('Accept-Encoding', 'gzip,deflate'),
('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'),
('Keep-Alive', '115'),
('Connection', 'keep-alive'),
('Cache-Control', 'max-age=0'),
('Referer', 'http://yahoo.com'),
]
But I want the website think that my urllib2 opener is a cell phone(doesn’t matter which one)
Thank you.
The
User-AgentHTTP header is often used by websites to identify your device. Pick one to match your intended device from: http://www.useragentstring.com/pages/useragentstring.php