def main(User, PassWord): r = requests.Session() # 进入官网获取cookies r.get(url='https://cunhua.me') # 加入x-www-form-urlencoded头信息 headers = {'Content-Type': 'application/x-www-form-urlencoded'} # 账号密码 data = 'fastloginfield=username&username='******'&password='******'&quickforward=yes&handlekey=ls' # 获取登陆后的账号 c = r.post( url= 'https://www.cunhua.me/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1', data=data, headers=headers) # 获取formhash c2 = r.get(url='https://www.cunhua.me/plugin.php?id=dc_signin') a = re.findall('formhash=(.*?)"', c2.text) # a[0]:formhash # 签到 data2 = 'formhash=' + a[ 0] + '&signsubmit=yes&handlekey=signin&emotid=8&referer=https%3A%2F%2Fwww.cunhua.cc&content=%E6%AF%8F%E5%A4%A9%E8%90%8C%E8%90%8C%E5%93%92%7E%7E' c3 = r.post( url='https://www.cunhua.me/plugin.php?id=dc_signin:sign&inajax=1', data=data2, headers=headers) mail(Content=str(c3.text), Title='村花签到情况') for i in range(0, 4320): c1 = r.get(url='https://cunhua.me') time.sleep(20) r.close()
def main(Cookie): r = requests.Session() # 进入官网获取cookies # 加入x-www-form-urlencoded头信息 headers = { 'Content-Type': 'application/x-www-form-urlencoded', 'Cookie': Cookie } # 账号密码 # 获取登陆后的账号 c = r.get(url="https://www.cunhua.nl/", headers=headers) # 获取formhash loginform = re.findall('name="formhash" value="(.*?)"', c.text)[0] print(loginform) qdUrl = "https://www.cunhua.nl/k_misign-sign.html?operation=qiandao&format=global_usernav_extra&formhash={}&inajax=1&ajaxtarget=k_misign_topb".format( loginform) # 签到 c3 = r.get(url=qdUrl, headers=headers) print(c3.text) mail(Content=str(c3.text), Title='村花签到情况') # 挂机 for i in range(0, 4320): c1 = r.get(url='https://cunhua.nl', headers=headers) time.sleep(20) r.close()
def main(Cookie): init(Cookie) r = requests.Session() # 进入官网获取cookies getHash = r.get(url='https://www.v2ex.com/mission/daily/redeem?once=81592', headers=heards, cookies=cookies) mail(getHash.text, "V2ex签到")
def main(User, PassWord): # 加入session r = requests.Session() # 进入官网获取cookies # 加入x-www-form-urlencoded头信息 headers = { 'Host': 'ji-c.pw', 'Connection': 'keep-alive', 'Content-Length': '43', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'X-Requested-With': 'XMLHttpRequest', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36', 'Sec-Fetch-Mode': 'cors', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Origin': 'https://ji-c.pw', 'Sec-Fetch-Site': 'same-origin', 'Referer': 'https://ji-c.pw/signin', 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Language': 'zh-CN,zh;q=0.9' } # 账号密码 data = 'email=' + User + '&passwd=' + PassWord + '' # 获取登陆后的账号 c = r.post(url='https://ji-c.pw/signin', data=data, headers=headers, verify=False) # 获取formhash print(chardet.detect(c.content)) # ascii 解码 headers1 = { 'Host': 'ji-c.pw', 'Connection': 'keep-alive', 'Content-Length': '0', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'X-Requested-With': 'XMLHttpRequest', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36', 'Sec-Fetch-Mode': 'cors', 'Origin': 'https://ji-c.pw', 'Sec-Fetch-Site': 'same-origin', 'Referer': 'https://ji-c.pw/user?ran=0.21882620098942573', 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Language': 'zh-CN,zh;q=0.9' } # 签到 c3 = r.post(url='https://ji-c.pw/user/checkin', headers=headers1, verify=False) Content = c3.content.decode('unicode_escape') mail(Content=Content, Title="几鸡流量签到情况") r.close()
def main(User, PassWord): r = requests.Session() # 进入官网获取cookies getHash = r.get( url='https://www.cunhua.cc/member.php?mod=logging&action=login') loginhash = re.findall('"loginfield_(.*?)">', getHash.text)[0] loginform = re.findall('formhash=(.*?)"', getHash.text)[0] # 加入x-www-form-urlencoded头信息 headers = {'Content-Type': 'application/x-www-form-urlencoded'} # 账号密码 data = 'fastloginfield=username&username='******'&password='******'&quickforward=yes&handlekey=ls' data = 'formhash=' + loginform + '&referer=https%3A%2F%2Fwww.cunhua.cc&loginfield=username&username='******'&password='******'&questionid=0&answer=' # 获取登陆后的账号 c = r.post( url= 'https://www.cunhua.cc/member.php?mod=logging&action=login&loginsubmit=yes&loginhash=' + loginhash + '&inajax=1', data=data, headers=headers) # 获取formhash # print(c.text) c2 = r.get(url='https://www.cunhua.cc/') a = re.findall('formhash=(.*?)"', c2.text) # a[0]:formhash # 签到 data2 = 'formhash=' + a[ 0] + '&signsubmit=yes&handlekey=signin&emotid=1&referer=https%3A%2F%2Fwww.cunhua.cc&content=%E8%AE%B0%E4%B8%8A%E4%B8%80%E7%AC%94%EF%BC%8Chold%E4%BD%8F%E6%88%91%E7%9A%84%E5%BF%AB%E4%B9%90%EF%BC%81' data2 = 'formhash=' + a[ 0] + '&signsubmit=yes&handlekey=signin&emotid=8&referer=https%3A%2F%2Fwww.cunhua.cc&content=%E6%AF%8F%E5%A4%A9%E8%90%8C%E8%90%8C%E5%93%92%7E%7E' c3 = r.post( url='https://www.cunhua.cc/plugin.php?id=dc_signin:sign&inajax=1', data=data2, headers=headers) mail(Content=str(c3.text), Title='村花签到情况') # 挂机 for i in range(0, 4320): c1 = r.get(url='https://cunhua.cc') time.sleep(20) r.close()
def alldone(): remain_links = getRemainUrlsLen() done_links = getDoneLinksLen() qiubai_len = getQiubaiLen() msg = "全部已跑完,耗时%s小时,共爬取%s条数据,共计%s个页面,爬取失败%s条链接,休息2小时。" % (d_hour, qiubai_len, done_links, remain_links) if mail(msg): print '邮件发送成功' else: print '邮件发送失败'
def letsgo(): stime = time.time() # get_ip() spiderGo() etime = time.time() d_hour = str(round((etime - stime) / 3600, 2)) remain_links = getRemainUrlsLen() done_links = getDoneLinksLen() qiubai_len = getQiubaiLen() msg = "第一轮已跑完,耗时%s小时,共爬取%s条数据,共计%s个页面,爬取失败%s条链接,休息2小时。" % (d_hour, qiubai_len, done_links, remain_links) print msg if mail(msg): print '邮件发送成功' else: print '邮件发送失败' time.sleep(7200)
def main(): global flag global start while flag: stime = time.time() if getRemainUrlsLen <= 500 and (not start): etime = time.time() d_hour = str(round((etime - stime) / 3600, 2)) remain_links = getRemainUrlsLen() done_links = getDoneLinksLen() qiubai_len = getQiubaiLen() msg = "全部已跑完,耗时%s小时,共爬取%s条数据,共计%s个页面,爬取失败%s条链接。恭喜您,糗事百科已通关。" % ( d_hour, qiubai_len, done_links, remain_links) if mail(msg): print '邮件发送成功' else: print '邮件发送失败' flag = False else: letsgo() start = False
def main(cookies, sum, idList, nubList): init(cookie=cookies) getYGB() mainApi(sum, idList, nubList) mail(str(list1), "斗鱼签到情况")
import cunhua, jiji, Douyu, configparser, hashlib, v2ex from urllib import parse import os, sys from Email import mail mail("定时任务", "Lunatic_Ubuntu") parent_dir = os.path.dirname(os.path.abspath(__file__)) config = configparser.RawConfigParser() config.read(parent_dir + '/Setting.conf', encoding='utf-8-sig') # Setting dDouyu = config.get('Setting', 'douyu') cCunhua = config.get('Setting', 'cunhua') jJiji = config.get('Setting', 'jiji') V2ex = config.get('Setting', 'v2ex') # cunhua cunhuaUser = None cunhuaPassWord = None if cCunhua == '1': cunhuaUser = config.get('cunhua', 'User') cunhuaUser = parse.quote(cunhuaUser) cunhuaPassWord = config.get('cunhua', 'PassWord') m = hashlib.md5() m.update(cunhuaPassWord.encode()) str_md5 = m.hexdigest() cunhuaPassWord = str_md5