Last active
May 31, 2023 04:24
-
-
Save za2016/15915e32659132e15d05082328b49b5a to your computer and use it in GitHub Desktop.
v2ex自动签到小脚本
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- coding=utf-8 -*- | |
import requests | |
import re | |
import sys | |
reload(sys) | |
sys.setdefaultencoding('utf8') | |
signin='http://v2ex.com/signin' | |
home='http://v2ex.com' | |
url='http://v2ex.com/mission/daily' | |
headers = { | |
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36', | |
'Origin': 'http://www.v2ex.com', | |
'Referer': 'http://www.v2ex.com/signin', | |
'Host': 'www.v2ex.com', | |
} | |
data={} | |
def sign(username,passwd): | |
try: | |
session=requests.Session() | |
session.headers=headers | |
loginhtm=session.get(signin).content | |
usernameform=re.findall('<input type="text" class="sl" name="(.*?)"',loginhtm)[0] | |
passwdform=re.findall('<input type="password" class="sl" name="(.*?)"',loginhtm)[0] | |
onceform=re.findall('<input type="hidden" value="(.*?)" name="once" />',loginhtm)[0] | |
print usernameform | |
print passwdform | |
print onceform | |
data[usernameform]=username | |
data[passwdform]=passwd | |
data['once']=onceform | |
data['next']='/' | |
loginp=session.post(signin,data=data) | |
sign=session.get(url).content | |
qiandao=re.findall("location.href = '(.*?)'",sign)[0] | |
session.get(home+qiandao) | |
print u'签到成功' | |
except Exception,e: | |
print e | |
if __name__=='__main__': | |
#username,passwd更改为你自己的用户名、密码 | |
username='' | |
passwd='' | |
requests.packages.urllib3.disable_warnings() | |
sign(username,passwd) |
为什么qiandao输出的是'/auth/google?once=33741',而不是/mission/daily/redeem?once=33741'
现在运行提示 hostname 'www.v2ex.com' doesn't match 'manage.c3edge.com' 是不是因为https 的问题啊 ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://tumbzzc.com