美文网首页
某网站抢号脚本(python)

某网站抢号脚本(python)

作者: ZoranLee | 来源:发表于2020-10-14 12:08 被阅读0次

最近抢号一直抢不到,极为郁闷,于是就抓了抓数据,写了如下脚本:


  • python 3.7.7
# -*- coding: utf-8 -*-
__author__ = "zoranlee"

import requests
import json
import threading
import datetime


def crawl():
    # url中的参数需要根据自己的情况做调整
    url = ""
    #headers根据自己情况输入
    headers = """
Content-Type:application/json
Accept-Encoding:gzip, deflate, br
Connection:keep-alive
Accept:*/*
User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.17(0x17001124) NetType/WIFI Language/zh_CN
Content-Length:164
Accept-Language:zh-cn
    """
    headers = headers_to_dict(headers)

    payload = {
        '': '',
        '': '',
        '': '',
        '': 0,
        '': 1,
        '': 'small',
        '': ''
    }
    response = requests.post(url,data=json.dumps(payload), headers=headers, verify=False)
    print(response.text)

def headers_to_dict(headers):
    """
    将字符串
    '''
    Host: mp.weixin.qq.com
    Connection: keep-alive
    Cache-Control: max-age=
    '''
    转换成字典类型
    :param headers: str
    :return: dict
    """
    headers = headers.split("\n")
    d_headers = dict()
    for h in headers:
        h = h.strip()
        if h:
            k, v = h.split(":", 1)
            d_headers[k] = v.strip()
    return d_headers


def timeHanler():
    now = datetime.datetime.now()
    dateTime = datetime.datetime(2020, 10, 14, 11, 30, 00)
    print('定时任务',now,'等待时间',dateTime)
    if (now > dateTime):
        print('哈哈,开始抢号了...')
        crawl()
    global timer
    timer = threading.Timer(1, timeHanler)
    timer.start()

if __name__ == '__main__':
    timeHanler();

相关文章

网友评论

      本文标题:某网站抢号脚本(python)

      本文链接:https://www.haomeiwen.com/subject/kvoipktx.html