Post请求不会发送

2024-05-29 04:48:46 发布

您现在位置:Python中文网/ 问答频道 /正文

你好。我试图从eventStream中读取"line"的数据,并在请求的有效负载中使用该数据。 我已经将{line}添加到有效负载中,希望它能工作,但是运气不好。你知道吗

我的代码如下所示

import json
import requests
from sseclient import SSEClient as EventSource
url = "http://colorillo.com/draw.php"

querystring = {"ing":"_index"}

payload = {'l': '{line}', 'c': 'ffffff', 'w': '100', 'o': '100', 'f': '1', '_': 'false'}

headers = {
'content-type': "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
'Content-Type': "application/x-www-form-urlencoded",
'X-Requested-With': "XMLHttpRequest",
'Accept': "*/*",
'User-Agent': "PostmanRuntime/7.13.0",
'Cache-Control': "no-cache",
'Postman-Token': "a4cccbb2-ec51-4694-b198-e733f1f10e4c,ed3c968e-b8b2-4168-abef-51025096933d",
'Host': "colorillo.com",
'cookie': "i=cloyfj1bio8uvxlqrkfkczqxo1pmx7m5; o=100; w=15; c=t44q; h=_-g00000____5aU00bH_GqCFXg3g_SY0gtx1J808RNApYLbO6g41X1wo____T000R01Puw3rMVU0t44q7w3F0afp4NcjXz00; a=lnpe0l; oi=qld8gxkfrzalpvqgydze7dzbm8p1r2zp",
'accept-encoding': "gzip, deflate",
'content-length': "713",
'Connection': "keep-alive",
'cache-control': "no-cache"
}




url1 = 'http://colorillo.com/_watch//_index?_=1559545075281'
for event in EventSource(url1):
if event.event == 'message':
    try:
        change = json.loads(event.data)
    except ValueError:
        pass
    else:
        print('{ident} drew {status}'.format(**change))
        requests.request("POST", url, data=payload, headers=headers, params=querystring)

Tags: 数据importcomeventjsonhttpurlcache

热门问题