好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

http://code.google.com/p/pyv8/, pyv8爬虫专用

http://code.google.com/p/pyv8/, pyv8爬虫专用

class HTTPRefererProcessor(urllib2.BaseHandler):

    def __init__(self):

        self.referer = None 

    def http_request(self, request):

        if ((self.referer is not None) and

            not request.has_header("Referer")):

            request.add_unredirected_header("Referer", self.referer)

        return request 

    def http_response(self, request, response):

        self.referer = response.geturl()

        return response 

    https_request = http_request

    https_response = http_response 

def main():

    cj = CookieJar()

    opener = urllib2.build_opener(

        urllib2.HTTPCookieProcessor(cj),

        HTTPRefererProcessor(),

    )

    urllib2.install_opener(opener) 

    urllib2.urlopen(url1)  #打开第一个网址

    urllib2.urlopen(url2)  #打开第二个网址

if "__main__" == __name__:

    main()


CookieJar. extract_cookies ( response ,  request )

Extract cookies from HTTP  response  and store them in the  CookieJar , where allowed by policy.

The  CookieJar  will look for allowable  Set-Cookie  and  Set-Cookie2  headers in the  response  argument, and store cookies as appropriate (subject to the  CookiePolicy.set_ok()  method’s approval).

The  response  object (usually the result of a call to  urllib2.urlopen() , or similar) should support an  info()  method, which returns an object with a  getallmatchingheaders()  method (usually a  mimetools.Message  instance).

The  request  object (usually a  urllib2.Request  instance) must support the methods  get_full_url() ,  get_host() ,  unverifiable() , and get_origin_req_host() , as documented by  urllib2 . The request is used to set default values for cookie-attributes as well as for checking that the cookie is allowed to be set.

http://fly5.com.cn/p/p-like/python_https.html

http://www.cnblogs.com/xiaoxia/archive/2010/08/04/1792461.html?login=1

http://xiudaima.appspot.com/code/detail/14001

查看更多关于http://code.google.com/p/pyv8/, pyv8爬虫专用的详细内容...

  阅读:30次

CopyRight:2016-2025好得很程序员自学网 备案ICP:湘ICP备09009000号-16 http://haodehen.cn
本站资讯不构成任何建议,仅限于个人分享,参考须谨慎!
本网站对有关资料所引致的错误、不确或遗漏,概不负任何法律责任。
本网站刊载的所有内容(包括但不仅限文字、图片、LOGO、音频、视频、软件、程序等)版权归原作者所有。任何单位或个人认为本网站中的内容可能涉嫌侵犯其知识产权或存在不实内容时,请及时通知本站,予以删除。

网站内容来源于网络分享,如有侵权发邮箱到:kenbest@126.com,收到邮件我们会即时下线处理。
网站框架支持:HDHCMS   51LA统计 百度统计
Copyright © 2018-2025 「好得很程序员自学网
[ SiteMap ]