Reputation: 35109
I found this website: https://panopticlick.eff.org/ That basically gives you some information of your browser. And it raised a question. so i was trying to create an urlllib2 opener and only thing I did is changed it's user-agent: so my opener looks like that:
class URLOpener():
def opener(self,user_agent):
cj=cookielib.CookieJar()
#Process Hadlers
opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders=[
('User-Agent', user_agent),
('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'),
('Accept-Language', 'en-gb,en;q=0.5'),
('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'),
('Keep-Alive', '115'),
('Connection', 'keep-alive'),
('Cache-Control', 'max-age=0'),
]
return opener
My question is how can I add something like this to my URLOpener:
Upvotes: 0
Views: 280
Reputation: 17629
You can't.
Most of those things are not passed by your browser to the web server. The reason that panopticlick can display those values is that it uses Javascript to access them.
You can see this for yourself. In Chrome or firefox open up the network tab in the developer console and look at the actual headers that are being sent when you make a request to a website.
Upvotes: 2