文档章节

使用树莓派自动签到贴吧,京东

l
 lykin1972
发布于 2016/12/07 13:11
字数 503
阅读 79
收藏 0

crontab -e

3 0 * * * nohup python -u /home/pi/work/baidu/check_in.py > /home/pi/work/logs/baidu/check_in.log 2>&1 &
3 0 * * * python /home/pi/work/jd/check_in.py
# coding: utf-8
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )
import requests
import re

num = 0
num_error = 0
ok_num = 0
error_num = 0
Cookie = 'Your cookie'
headers = {
    'Accept':'application/json, text/javascript, */*; q=0.01',
    'Accept-Encoding': 'gzip, deflate',
    'Accept-Language': 'zh-CN,zh;q=0.8,en;q=0.6',
    'Connection': 'keep-alive',
    'Content-Length': '61',
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    'Cookie': Cookie,
    'DNT': '1',
    'Host': 'tieba.baidu.com',
    'Origin': 'http://tieba.baidu.com',
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36',
    'X-Requested-With': 'XMLHttpRequest',
}
headers1 = {
    "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
    "Accept-Encoding":"gzip, deflate, sdch",
    "Accept-Language":"zh-CN,zh;q=0.8",
    "Cache-Control":"max-age=0",
    "Connection":"keep-alive",
    "Cookie": Cookie,
    "Host":"tieba.baidu.com",
    "Upgrade-Insecure-Requests":"1",
    "User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36"
}

url_forum = 'http://tieba.baidu.com/f/like/mylike'
r2 = requests.get(url_forum, headers=headers1)
search = re.findall(ur'a href=.*?title="(.+?)">', r2.text)
num_forum = len(search)
print 'num_forum', num_forum

num = 0
num_error = 0
ok_num = 0
error_num = 0

pid = True
while num != num_forum and pid:
    for i in search:
        payload = {'ie': 'utf-8', 'kw': i, 'tbs': 'fb6ecec1996df5d41435580832'}
        r = requests.post('http://tieba.baidu.com/sign/add', data=payload, headers=headers, timeout=3)
        html = r.text.decode('raw_unicode_escape')
        print "%s %s ..." % ("Execute task:", i)
        if html == u'{"no":1101,"error":"亲,你之前已经签过了","data":""}':
            ok_num += 1
            print "%s is repeat task." % i
        else:
            ok_num += 1
            print "%s finished." % i

    if ok_num == num_forum:
        pid = False
    else:
        error_num += 1
        if error_num == 5:
            pid = False
print 'over'
# coding: utf-8
import requests
import re


# Please replace your cookie here.
Cookie = ""

headers = {
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
    "Accept-Encoding": "gzip, deflate, sdch, br",
    "Accept-Language": "zh-CN,zh;q=0.8",
    "Cache-Control": "max-age=0",
    "Connection": ":keep-alive",
    "Cookie": Cookie,
    "Host": "vip.jd.com",
    "Upgrade-Insecure-Requests": "1",
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36"
}

url_forum = 'http://vip.jd.com'
print 'curl', url_forum
r = requests.get(url_forum, headers=headers)
isLogin = re.findall(ur'pageConfig.isLogin="(.+?)"', r.text)
token = re.findall(ur'pageConfig.token="(.+?)"', r.text)
print 'token :', token[0], ', isLogin:', isLogin[0]

url_forum = 'https://vip.jd.com/common/signin.html?token='+token[0]
print 'curl', url_forum
r2 = requests.get(url_forum, headers=headers)
print r2.text

headers = {
    "Accept": "*/*",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "zh-CN,zh;q=0.8",
    "Connection": ":keep-alive",
    "Cookie": Cookie,
    "Host": "vip.jr.jd.com",
    "Origin": "https://vip.jr.jd.com",
    "Referer": "https://vip.jr.jd.com/",
    "X-Requested-With": "XMLHttpRequest",
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36"
}

url_forum = 'https://vip.jr.jd.com/newSign/doSign'
print 'curl', url_forum
r = requests.post(url_forum, headers=headers)
print r.text

# Glod lottery, once everyday.
url_forum = 'http://vip.jr.jd.com/award/drawAward'
#url_forum = ' http://vip.jr.jd.com/newSign/doSign'
print 'curl', url_forum
r = requests.post(url_forum, headers=headers)
print r.text


url_forum = 'http://ld.m.jd.com/SignAndGetBeans/signStart.action?sid=210aafce2985f69c0ebfeae0f5459fbw'
r = requests.get(url_forum)
print 'curl', url_forum
print r.text

over

© 著作权归作者所有

共有 人打赏支持
l
粉丝 0
博文 8
码字总数 3986
作品 0
岳阳
私信 提问
树莓派笔记02—树莓派硬件环境准备

在开始玩转树莓派之前,我们需要了解下树莓派的硬件配置以及所需要的配件。跟电脑PC机类似,树莓派也需要必要的输入输出设备才能工作。 1. 树莓派3B+ 2018年3月14日,树莓派基金会正式发布新...

TonyCode
08/03
0
0
10 个最值得关注的树莓派博客

如果你正在计划你的下一个树莓派项目,那么这些博客或许有帮助。 网上有很多很棒的树莓派爱好者网站、教程、代码仓库、YouTube 频道和其他资源。以下是我最喜欢的十大树莓派博客,排名不分先...

作者: Ben Nuttall
11/02
0
0
子豪兄教你在树莓派上安装OpenCV

子豪兄教你在树莓派上安装OpenCV 本文介绍了如何在树莓派上安装分别运行在Python2和Python3的OpenCV。 运行在Python2上的OpenCV安装非常简单,几行命令即可搞定。运行在Python3上的OpenCV安装...

同济子豪兄
10/05
0
0
raspberrypi的相关网址

一、NOOBS安装 NOOBS使用说明书 http://www.shumeipai.net/thread-20009-1-1.html NOOBS自定义多系统启动 https://www.jianshu.com/p/afbcd17b785d NOOBS安装自定义系统 https://blog.csdn.......

mbzhong
11/14
0
0
基于树莓派如何开发机器人(附PPT+视频) | 硬创公开课

导语:树莓派是为学习计算机编程教育而设计的一种微型电脑,其系统是基于Linux的, 虽然只有信用卡大小,但视频、音频等功能通通皆有,可谓是“麻雀虽小,五脏俱全”。因此自问世以来,受到了...

金红
2017/03/09
0
0

没有更多内容

加载失败,请刷新页面

加载更多

kubernetes notes

Error from server (ServerTimeout): error when creating "mysql.yaml": No API token found for service account "default", retry after the token is automatically created and added t......

kut
8分钟前
1
0
代理模式---静态代理

package com.atguigu.java; //接口的应用:代理模式---静态代理。 public class ProxyTest { public static void main(String[] args) { NetWork work = new RealServer(); ProxyServer pro......

architect刘源源
24分钟前
2
1
工作中的一些Git使用

git stash list 查看所有stash git stash apply 0 应用序号为0那个stash并且不删除它 git stash pop 0 应用序号为0那个stash并且删除删除删除它 git stash save "env" stash当前的改动并且取...

-___-
51分钟前
1
0
C# webservice 配置总结

为了方便下次查看,把总结配置文件放这里,看的方便。 <?xml version="1.0" encoding="utf-8"?><!-- 有关如何配置 ASP.NET 应用程序的详细消息,请访问 http://go.microsoft.com/f...

轻轻的往前走
今天
0
0
SpringCloud之Eureka

Eureka简介 什么是Eureka? Eureka是一种基于rest提供服务注册和发现的产品: Eureka-Server: 用于定位服务,以实现中间层服务器的负载平衡和故障转移。 Eureka-client:用于服务间的交互,内...

lc_fly1
今天
4
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部