51CTO自動領豆(Python)

一、環境配置

Python X86官方下載X64官方下載

二、自動登錄源代碼(來源於網絡)

 _login_url = 'http://home.51cto.com/index.php?s=/Index/doLogin'
    _method = 'post'
    #email 51cto登錄用戶名或郵箱
    #passwd 51cto登錄密碼
    _login_data = {
                   'email':'***@qq.com',\
                   'passwd':'***',\
            }
    _headers = [
                ('host','home.51cto.com'),\
                ('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2'),\
                ('Referer','http://home.51cto.com/index.php?s=/Index/index/reback/http%253A%252F%252Fwww.51cto.com%252F/')\
        ]
    _data = {
             'cookie_file_path':'./51cto_cookies.dat'
        }
    _re = r'src="(.+?)"'
    _version = '0.1'
    _connect_info = {}
    def __init__(self):
        self._connect_info['cookie'] = cookielib.LWPCookieJar()
        try:
            self._connect_info['cookie'].revert(self._data['cookie_file_path'])
        except Exception,e:             
            print e
        self._connect_info['cookie_processor'] = urllib2.HTTPCookieProcessor(self._connect_info['cookie'])
        self._connect_info['post_data'] = urllib.urlencode(self._login_data)
    def open(self):
        opener = urllib2.build_opener(self._connect_info['cookie_processor'])
        opener.addheaders = self._headers
        urllib2.install_opener(opener)

        
        #opener.open(request)
        request = urllib2.Request(self._login_url,self._connect_info['post_data'])
        conn = opener.open(request)
        if(conn.geturl() == self._login_url):
            self._connect_info['cookie'].save(self._data['cookie_file_path'])
        else:
            pass
        #根據js中的鏈接連接登錄
        partner = re.compile(self._re)
        match = partner.findall(conn.read())
        
        for item in match:
            opener.open(item)
              
        
        #登錄成功開始領豆
        url = 'http://down.51cto.com/download.php'
        data = {'do':'getfreecredits','t':random.random()}
        opener.open(url, urllib.urlencode(data))
        #html = opener.open('http://down.51cto.com/')
        
        #領無憂幣
        url = 'http://home.51cto.com/index.php?s=/Home/toSign'
        data = {'s':''}
        opener.open(url, urllib.urlencode(data))

if __name__ == '__main__':
    login_51cto = Login()
    login_51cto.open()
        

自行把賬號密碼換成自己的,另存爲“51CTO.py”(名字沒影響)


三、VBS實現自動化

如果你能接受DOS黑框框的話可以直接上批處理

這裏上個最簡單的VBS執行批處理

1.創建批處理

wscript.sleep 10000>C:\Sleep.Vbs :延遲設置10秒
閃訊.lnk :和批處理放一起就寫相對路徑了
start /wait C:\Sleep.Vbs :延遲
51CTO.lnk :和批處理放一起就寫相對路徑了
迅雷樹.lnk  :和批處理放一起就寫相對路徑了

2.VBS隱藏黑框運行

dim wsh
set wsh=createobject("wscript.shell")
wsh.run "啓動.bat",vbhide  '和批處理放一起就寫相對路徑了

現在只要運行這個VBS就能自動領豆了


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章