在使用python请求发布此数据时遇到问题吗?

时间:2018-07-27 03:25:15

标签: python-3.x python-requests

因此,我尝试使用python请求发布此数据,但是我遇到了两个问题。  1.数据发布不正确,不确定原因。我认为即时通讯使用所有正确的标题  2.当我尝试打印出response.content时,我得到了一堆奇怪的字符输出,根本没有真实的文本。

有人知道吗?

import requests
import time
import random
import json
import bs4
from bs4 import BeautifulSoup as soup
from python_anticaptcha import AnticaptchaClient, NoCaptchaTaskProxylessTask



#sess = requests.Session()
#sess.get("https://slamjamsocialism-drops.com/drops/138")

sess = requests.Session()
link = "https://slamjamsocialism-drops.com/drops/138"
anti_api_key = "my api key"
site_key = "6LfYhz0UAAAAAJFKp28Sg0NnAEIPMfKI1RJSGsdB"

client = AnticaptchaClient(anti_api_key)
task = NoCaptchaTaskProxylessTask(link, site_key)
job = client.createTask(task)
job.join()
captcha = job.get_solution_response()



headers = {

    "authority": "slamjamsocialism-drops.com",
"method": "POST",
"path": "/graphql",
"scheme": "https",
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "en-US,en;q=0.9",
"authorization": "null",
"content-length": "718",
"content-type": "application/json",
"dnt": "1",
"origin": "https://slamjamsocialism-drops.com",
"referer": "https://slamjamsocialism-drops.com/drops/138",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
}

data = {


   "query":"mutation RequestOrdertMutation($data: OrderRequestInput!) {\n  requestOrder(data: $data)\n}\n",
   "operationName":"RequestOrdertMutation",
   "variables":{
      "data":{
         "firstName":"blah",
         "lastName":"blahblah",
         "email":"testing1236@kornkicks.club",
         "phone":"193482345",
         "country":"840",
         "city":"new cumberland",
         "order":[
            {
               "product":"114",
               "size":"42 ½"
            }
         ],
         "raffle":"138",
         "captcha": captcha

      }
   }
}


response = sess.post('https://slamjamsocialism-drops.com/drops/138', headers=headers, json=data)
print(response.status_code)
print(response.text)

1 个答案:

答案 0 :(得分:0)

  1. 您的反验证码机制可能无效。
  2. WHERE ( [Value1] <= 0 OR [Value2] <= 0 OR [Value3] <= 0 ) AND [DATE_TIME] >= [DATE_TIME] 依赖于具有正确编码的响应头将内容解码为文本,如果不正确,它将尝试做出最佳猜测,不一定是准确的。查看response.texts的内容并确定自己的编码方式后,请将response.encoding设置为正确的编码。