我是如何使用 Python 优雅的薅到网易uu的羊毛的

外服会员活动价, 需要准点限量抢购, 寻思更优雅的方法

ref: https://shop.uu.163.com/app/mall/oversea/detail?type=561

分析下单页面, 点击下单实则进行 Ajax 请求
祭出 requests
对这个 Ajax 进行狂轰滥炸, 本来想加个延时的, 但是, 男人要猛一点才有魅力


import requests


headers = {
    'Cookie': 'uid=*******************;',
    'X-Requested-With': 'XMLHttpRequest',
}

url = 'https://shop.uu.163.com/app/mall/order/oversea/create?good_type=561&pay_type=2'

i = 0
while 1:
    i += 1
    try:
        res = requests.get(url, headers=headers)
    except Exception:
        continue

    json = res.json()
    if json != {'error': '很抱歉,兑换物品没有剩余了'}:
        print('bingo')
        break
    print(json, i)

小插曲: 正常情况带上 cookie 就行的, 这里需要多加一个来自 XHR 的头
'X-Requested-With': 'XMLHttpRequest'
也是进过多次实验得出的结论
猜测网易后台有通过类似 phalcon 的 isAjax() 方法判断请求类型

截图纪念, 人生中第二个十年
happy birthday

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值