诸位, V2EX 自动签到脚本崩了,你们发现了吗?

2016-04-23 10:35:16 +08:00
 fy

直接上代码,自用于 python 3.4 环境测试通过

自行修改 u:'username', p:'password' 这两个 username password 字符串为自己的帐号密码

# coding:utf-8

import re
import requests

session = requests.Session()

# 领取 X 铜币
# 每日登录奖励已领取

base_headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.71 Safari/537.36 OPR/35.0.2066.23 (Edition beta)', 'Referer': 'http://v2ex.com/signin'}

session.headers = base_headers

resp = session.get('http://v2ex.com/signin')
u, p = re.findall(r'class="sl" name="([0-9A-Za-z]{64})"', resp.text)
once_code = re.search(r'value="(\d+)" name="once"', resp.text).group(1)

resp = session.post('http://v2ex.com/signin', {u:'username', p:'password', 'once':once_code, 'next':'/'})
resp = session.get('http://v2ex.com/mission/daily')

if u'每日登录奖励已领取' in resp.text:
    print('Already got it.')
else:
    resp = session.get('http://v2ex.com' + re.search(r'/mission/daily/redeem\?once=\d+', resp.text).group())
    print(resp.ok)

7803 次点击
所在节点    分享创造
52 条回复
vmebeh
2016-04-24 11:24:30 +08:00
@aivier 昨天在隐身模式测试的,打开登录页后才开的扩展,刚才发现新开标签就可以了; 1Password 还记录了 type 字段。
fy
2016-04-24 13:47:03 +08:00
@Clarencep 脚本总有挂的时候,真挂的时候就算是 lxml 或者 bs 都救不回来,还少一个二进制依赖( lxml ),而且还不是生产环境,何必折腾。
taxiangdeni
2016-04-24 14:21:41 +08:00
@shulen V2EX 的领取铜币的 url 是动态的

<input type="button" class="super normal button" value="领取 X 铜币" onclick="location.href = '/mission/daily/redeem?once=15881';">

once 的是值是变化的,在你的 config.js 文档里应该以正则表达式进行获取 once 的值吧
EchoWhale
2016-04-25 09:07:05 +08:00
login 的表单,之前用户名字段是 u ,密码字段是 p ,现在改为一串长长的随机字符了
zenxds
2016-04-25 10:04:24 +08:00
node cheerio 分分钟搞定,$('input[name="once"]').attr('value'), $('input.sl:text').attr('name'), $('input.sl:password').attr('name')
shulen
2016-04-25 20:29:35 +08:00
@taxiangdeni config 里面是随便设的一个值,后面每次访问页面都需要重新获取 once
hxndg
2016-04-28 15:20:57 +08:00
表示变成随机字符串之后提取以下就可以了,。。。好像 reference 也需要不能为空。。。
G0D
2016-08-25 08:52:25 +08:00
又挂了
xuboying
2016-08-25 23:36:32 +08:00
崩了,求更新,自己改了一下还是不对
fy
2016-08-28 00:46:15 +08:00
G0D
2016-08-28 08:09:37 +08:00
@fy 谢谢
xuboying
2016-09-09 22:29:36 +08:00
@fy Thanks

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/273827

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX