首页 > 编程语言 > 详细

python 简单的post请求

时间:2021-08-07 23:25:45      阅读:32      评论:0      收藏:0      [点我收藏+]
# -*- coding: utf-8 -*-
import random
import os, threading, datetime
import requests, json

def createPhone():
    prelist = ["130", "131", "132", "133", "134", "135", "136", "137", "138", "139",
               "147", "150", "151", "152", "153", "155", "156", "157", "158", "159",
               "186", "187", "188", "189"]
    new_phone = random.choice(prelist) + "".join(random.choice("0123456789") for i in range(8))
    # print(new_phone)
    return new_phone


def req_thread(url,params):
    headers = {"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1",‘Content-Type‘:‘application/json;charset=UTF-8‘
               ,"Accept": "application/json, text/plain, */*"}
    print(params)
    r = requests.post(url, params=params, headers=headers,data=params);
    print(r.text)


def teThread():
    st = datetime.datetime.now()
    phone = createPhone()
    url = "http://域名+ 路径"
    params = {"phone": phone}
    data = json.dumps(params)
    m = threading.Thread(target=req_thread(url,data), args=())
    m.run()
    end = datetime.datetime.now()


if __name__ == ‘__main__‘:
    teThread()

?

python 简单的post请求

原文:https://blog.51cto.com/u_11639179/3309240

(0)
(0)
   
举报
评论 一句话评论(0
分享档案
最新文章
教程昨日排行
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!