乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Python 模擬登錄及表單提交 - 代碼分享 - 開源中國社區(qū)

       ganame 2011-02-13

      01 # -*- coding: utf-8 -*-  
      02 import re  
      03 import urllib  
      04 import urllib2  
      05 import cookielib  
      06     
      07 #獲取CSDN博客標(biāo)題和正文  
      08 url = "http://blog.csdn.net/[username]/archive/2010/07/05/5712850.aspx"  
      09 sock = urllib.urlopen(url)  
      10 html = sock.read()  
      11 sock.close()  
      12 content = re.findall('(?<=blogstory">).*(?=<p class="right artical)', html, re.S)  
      13 content = re.findall('<script.*>.*</script>(.*)', content[0], re.S)  
      14 title = re.findall('(?<=<title>)(.*)-.* - CSDN.*(?=</title>)', html, re.S)  
      15 #根據(jù)上文獲取內(nèi)容新建表單值  
      16 blog = {'spBlogTitle': title[0].decode('utf-8').encode('gbk'), #百度博客標(biāo)題  
      17         'spBlogText': content[0].decode('utf-8').encode('gbk'),#百度博客內(nèi)容  
      18         'ct': "1",  
      19         'cm': "1"}  
      20 del content  
      21 del title  
      22     
      23 #模擬登錄  
      24 cj = cookielib.CookieJar()  
      25 #用戶名和密碼  
      26 post_data = urllib.urlencode({'username': '[username]', 'password': '[password]', 'pwd': '1'})  
      27 #登錄路徑  
      28 path = 'https://passport.baidu.com/?login'  
      29 opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))  
      30 opener.addheaders = [('User-agent', 'Opera/9.23')]  
      31 urllib2.install_opener(opener)  
      32 req = urllib2.Request(path, post_data)  
      33 conn = urllib2.urlopen(req)  
      34     
      35 #獲取百度發(fā)布博客的認(rèn)證令牌  
      36 bd = urllib2.urlopen(urllib2.Request('http://hi.baidu.com/[username]/creat/blog')).read()  
      37 bd = re.findall('(?<=bdstoken\" value=\").*(?=ct)', bd, re.S)  
      38 blog['bdstoken'] = bd[0][:32]  
      39 #設(shè)置分類名  
      40 blog['spBlogCatName'] = 'php'  
      41 #比較表單發(fā)布博客  
      42 req2 = urllib2.Request('http://hi.baidu.com/[username]/commit', urllib.urlencode(blog))  
      43     
      44 #查看表單提交后返回內(nèi)容  
      45 print urllib2.urlopen(req2).read()  
      46     
      47 #請(qǐng)將[username]/[password]替換為您的真實(shí)用戶名和密碼

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多