Re: [Tutor] user agent
Kent Johnson [EMAIL PROTECTED] wrote Alan, I think you might have this backwards. I think jeremiah wants to specify the user agent on the client side of the connection. Ah! In that case it makes sense. Ignore my ramblings :-) Alan G ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] user agent
I'm trying to force the user agent in a python login script... My question is what are the possible user agents I can specify and how do I print the user agent at the end of the script so I know that it was accurately saved. Here is the first bit of my code. Any suggestions? thx, JJ == #!/usr/bin/python import cookielib, urllib2 import urllib cookie_jar = cookielib.CookieJar() opener = urllib2.build_opener( urllib2.HTTPCookieProcessor(cookie_jar) ) User Agent Setting - change ua_value to modify user agent options are: 'Mozilla/5.0', 'ie5' ua_value=ie5 opener.addheaders = [('User-agent', ua_value)] Disclaimer: The information contained in this transmission, including any attachments, may contain confidential information of Panasonic Avionics Corporation. This transmission is intended only for the use of the addressee(s) listed above. Unauthorized review, dissemination or other use of the information contained in this transmission is strictly prohibited. If you have received this transmission in error or have reason to believe you are not authorized to receive it, please notify the sender by return email and promptly delete the transmission. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] user agent
jeremiah [EMAIL PROTECTED] wrote I'm trying to force the user agent in a python login script... Might I ask why? It should never be necessary and is extremely user hostile. Especially given that many modern browsers are capable of emulating the troublesome ones - ie IE! And future versions might change the rules and you then have a huge maintenance overhead of keeping your list of browsers updated. If at all possible it's better to put the effort into making your code browser neutral. Which mainly meams avoiding unusual HTML constructs, using ECMAscript rather than any vendor specific variant of JavaScript and not trying to control layout and style too closely (that's what PDF is for!) question is what are the possible user agents I can specify Thats a changing question because the number of browsers and what they report to the server is changing constantly. Its usually more common to simply specify a small subset of the most common ones and anyone with the audacity to prefer an alternative hgets a more or less rude message telling them to pick another browser print the user agent at the end of the script so I know that it was accurately saved. Here is the first bit of my code. Its stored in an environment variable. How you access that will depend on your server/framework but as a last resort os.getenv() should work. -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] user agent
On Wed, Sep 24, 2008 at 7:55 PM, Alan Gauld [EMAIL PROTECTED] wrote: jeremiah [EMAIL PROTECTED] wrote I'm trying to force the user agent in a python login script... Might I ask why? It should never be necessary and is extremely user hostile. Especially given that many modern browsers are capable of emulating the troublesome ones - ie IE! And future versions might change the rules and you then have a huge maintenance overhead of keeping your list of browsers updated. Alan, I think you might have this backwards. I think jeremiah wants to specify the user agent on the client side of the connection. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] user agent
On Wed, Sep 24, 2008 at 6:55 PM, jeremiah [EMAIL PROTECTED] wrote: I'm trying to force the user agent in a python login script... My question is what are the possible user agents I can specify Here is a rather long list: http://www.user-agents.org/ but presumably there is a particular browser you want to emulate? and how do I print the user agent at the end of the script so I know that it was accurately saved. I don't understand where you want to save the user agent. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor