Serge Orlov 写道: > Bo Yang wrote: > >> Hi , >> Recently I use python's urllib2 write a small script to login our >> university gateway . >> Usually , I must login into the gateway in order to surf the web . So , >> every time I >> start my computer , it is my first thing to do that open a browser to >> login the gateway ! >> >> So , I decide to write such a script , sending some post information to >> the webserver >> directly to login automatic once the computer is on . And I write the >> code below : >> >> urllib2.urlopen(urllib2.Request(url="https://202.113.16.223/php/user_login.php", >> data="loginuser=0312889&password=o127me&domainid=1&refer=1& logintype= >> #####")) >> >> In the five '#' above , I must submit some Chinese character , but the >> urllib2 complain >> for the non-ascii characters . >> > > I guess the server expect that a browser is coming from page > https://202.113.16.223/, so the url should be submitted in the encoding > of page https://202.113.16.223/ which is gb2312. > > urllib2.urlopen(urllib2.Request(url="https://202.113.16.223/php/user_login.php", > data=u"loginuser=0312889&password=o127me&domainid=1&refer=1& logintype= > 写道".encode('gb2312'))) > > should work > > Yeah , and it works ! Thank you !
-- http://mail.python.org/mailman/listinfo/python-list