Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

python·ÃÎÊÍøÒ³´øcookieÎÊÌâ

ÎÒÏÖÔÚÒªÓÃpython·ÃÎÊÒ»¸öÍøÕ¾µÄÍøÒ³£¬È¡µÃһЩÐÅÏ¢
µ«ÊÇÍøÕ¾ÒªÇóÏȵǼ£¬È»ºó²ÅÄܼÌÐø·ÃÎÊ£¬µÇ¼¹ý³Ì¾ÍÊÇдÁ˸öcookie
ÇëÎÊÏÂpython·ÃÎÊÍøÒ³Ôõô±£³ÖסcookieÄØ£¿

ÎÒÓõÄÊÇpython3.1£¬Ö»ÓÐurllibºÍhttpÁ½¸ö¿âÁË
ÍøÉÏÕÒÁËһЩ´úÂ룬¶¼ÊÇpython2.x°æ±¾µÄ

ÄÄλºÃÐĵÄÐÖµÜд¼¸¾äpython3.1µÄ´úÂ룬¸Ð¼¤²»¾¡
ÎÒÒ²ÏëÖªµÀ


Çë²Î¿´cookiejar

ÎÒÒ²ÏëÖªµÀ


˳±ãÎÊÒ»¸öÎÊÌ⣬ÈçºÎ¶ÔÒ³ÃæÀïµÄÌõ¼þÑ¡ÔñºóÔÙ·ÃÎÊÕ¾µã£¬ÓеÄÕ¾µã±ÈÈç´øËÑË÷¹¦ÄÜ£¬ÐèҪѡÔñËÑË÷Ìõ¼þ£¬È»ºóÔÙÈ·ÈÏ·¢³öÓÉÕ¾µã·µ»Ø²éÑ¯Ò³Ãæ¡£
ÔÚpythonÀïÈçºÎ¶ÔÕâЩËÑË÷Ìõ¼þ½øÐÐÑ¡Ôñѽ£¿

ÖªµÀÁË£¬ÓÃPAMIE

ÒýÓÃ
Õâ¸ö¼òµ¥

Python code# coding: UTF-8import urllib2, httplib, urllib, sys, cookielibif__name__=="__main__":
    cj= cookielib.CookieJar()
    body= (('staffNo','mopÓû§Ãû'), ('password','mopÃÜÂë'))
    opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
    opener.addheaders= [('User-agent','Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)')]
    urllib2.install_opener(opener)
    req=urllib2.Request(url,urllib.urlencode(body))
    u=urllib2.urlopen(req)#print u.read().decode('utf-8').encode('gbk')    url='http://app.mop.com/tycoon/'
    u= urllib2.urlopen(url)
    u


Ïà¹ØÎÊ´ð£º

Ë­ÍÆ¼öÒ»±¾Ñ§Ï°PYTHONµÄÊ飬лл

Ë­ÍÆ¼öÒ»±¾Ñ§Ï°PYTHONµÄÊ飬лл
¡¶python¼òÃ÷½Ì³Ì¡·£¬¡¶pythonºËÐıà³Ì¡·

×÷Ϊϵͳ¹ÜÀí·½Ãæ£¬¡¶Python UNIXºÍLinuxϵͳ¹ÜÀíÖ¸ÄÏ¡·ÊDZ¾·Ç³£²»´íµÄÊé¡£
http://club.book.csdn.net/pic3/255142.jpg

ÒýÓÃ
×÷Î ......

python listÖÐÌí¼ÓÀà¶ÔÏóµÄÎÊÌâ

ÔÚlistÖÐÌí¼ÓÒ»¸öÀàµÄ¾Ö²¿±äÁ¿ ÕâÑù×öÊÇ·ñºÏ·¨ Çë¿´ÏÂÃæÀý×Ó:
Python code:

class A():
def __init__( self ):
self.__a = 0
self.__b = 'hello'
def get_a( self ):
ret ......

pythonÈçºÎÉèÖÃCLOSE_WAIT״̬ռÓõĶ˿ÚÖØÓÃ

·¢ÏÖpython2.6
import httplib
conn=httplib.HTTPSConnection('x.x.x.x')
conn.request('','')
rd=conn.getresponse()
conn.close()
ÕâÑù½áÊøºó»á±ä³ÉCLOSE_WAIT״̬£¬ÎÒ ......

ÎÒÓ¦¸ÃÑ¡Ôñperl»¹ÊÇpython»¹ÊÇÆäËû°¡ лл

ÎÒµÄÑо¿·½ÏòÊÇÖÐÎÄÐÅÏ¢´¦ÀíÖеÄÎı¾·ÖÀàÏà¹ØµÄ¶«¶«
ÔÙ¾ßÌåÒ»µã¾ÍÊÇÎı¾ÇãÏòÐÔ£¬Çé¸Ð·ÖÀàÖ®ÀàµÄ¶«¶«¡£¡£¡£¡£
ÏëѧһÃŽű¾ÓïÑÔÀ´±à³Ì¡£¡£¡£
Ï£Íû´ó¼Ò°ïÃ¦ÍÆ¼öһϰ¡ лл
Õâ¶ÔÎÒÀ´ËµºÜÖØÒªµÄ
Ó¦¸Ã¶¼ÐÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ