2006年11月27日 星期一 11:52
rt 怎么使用代理连接网页?
2006年11月27日 星期一 11:53
2006年11月27日 星期一 12:53
ÎÒÔÚpythondoc.chmÉϳµÄ£¬²»ÖªµÀÄܲ»ÄܰïÄãһæ¡£ºìÉ«ÊÇÎҼӵģ¬Ã»¼Óʱ±àÒë²»¹ý£¬²»ÖªµÀÊÇÎÒ´íÁË£¬»¹ÊÇÎĵµÉÏÓÐBUG¡£
import urllib2
proxy_handler = urllib2.ProxyHandler({'http': '
http://www.example.com:3128/'})
££Õâ¸öÓ¦µ±ÊÇ´úÀíÉèÖÃÁË¡£
proxy_auth_handler = urllib2.HTTPBasicAuthHandler()
proxy_auth_handler.add_password('realm', 'host', 'username', 'password')
££Õâ¸öÊÇ´úÀíÊÚȨ¡£
££Õâ¸öº¯ÊýÓе㲻Ã÷°×£¬Ö÷ÒªÊÇrealmºÍhostÕâÁ½¸ö²ÎÊýÒâÒ壬ʵ¼ÊÖÐÈçºÎÉè¡£¸ßÊÖÖ¸½Ìһϣ¬DOCÉÏ
££µÄ½âÊÍÈçÏ£º
££uri can be either a single URI, or a sequence of URIs. realm, user and
passwd must be ££strings. This causes (user, passwd) to be used as
authentication tokens when ££authentication for realm and a super-URI of any
of the given URIs is given.
opener = urllib2.build_opener(proxy_handler, proxy_auth_handler)
# This time, rather than install the OpenerDirector, we use it directly:
opener.open('http://www.example.com/login.html')
2006/11/27, xbsun <xbsun在metarnet.com>:
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20061127/cddad321/attachment.html
2006年11月27日 星期一 17:32
A simple example:
*import urllib
MYPROXY = {'http':'http://proxy.sdc.ubisoft.org:3128'}
TARGET = "http://www.google.com"
def main():
page = urllib.urlopen( TARGET, proxies = MYPROXY )
page.close()
main()*
On 11/27/06, tdus lost <tdus.lost at gmail.com> wrote:
> rt
> 怎么使用代理连接网页?
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
--
HIH,
Huang You Gong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20061127/8e6fce1d/attachment.htm
Zeuux © 2025
京ICP备05028076号