版本比较

密钥

  • 该行被添加。
  • 该行被删除。
  • 格式已经改变。

...

代码块
languagepy
from curl_cffi import requests

proxies = {
    'http': "http://127.0.0.1:10911", 
    'https': "http://127.0.0.1:10911",
}

# 正常情况是这样的
response = requests.get("https://apkpure.com/", proxies=proxies)
print("请求响应:", response.status_code)
print("网页标题:", response.text[:63])

# 返回:
# 请求响应: 403
# 网页标题: <!DOCTYPE html><html lang="en-US"><head><title>Just a moment...

# 使用 curl_cffi.requests请求
# impersonate参数指定了模拟Chrome浏览器的指纹
response = requests.get(
    "https://apkpure.com/", proxies=proxies, impersonate="chrome110")
print("请求响应:", response.status_code)
print("网页标题:", response.text[:63])
# 返回:
# 请求响应: 200
# 网页标题: <!DOCTYPE html><html lang="en"><head><title>Download APK on And

测试DEMO

View file
namecloudflare5s_demo.py

代码块
from curl_cffi import requests
import time


# 创建任务
def create_task(url, proxy):
    data = {
        # 填您自己的密钥
        "clientKey": clientKey,
        "task": {
        "type": "CloudFlareTaskS1",
        "websiteURL": url,
        "proxy": proxy
        }
    }
    url = "https://api.yescaptcha.com/createTask"
    response = requests.post(url, json=data).json()
    return response
  
# 获取结果
def get_task(task_id):
  url = "http://api.yescaptcha.com/getTaskResult"
  data = {
      # 填您自己的密钥
      "clientKey": clientKey,
      "taskId": task_id
  }
  response = requests.post(url, json=data).json()
  return response


# 完整的请求
def get_result(*args, **kwargs):
  uuid = create_task(*args, **kwargs)
  if not uuid or not uuid.get('taskId'):
    return uuid
  print("TaskID:", uuid)
  for i in range(30):
    time.sleep(3)
    result = get_task(uuid.get('taskId'))
    if result.get('status') == 'processing':
        continue
    elif result.get('status') == 'ready':
        return result
    else:
        print("Fail:", result)



if __name__ == '__main__':
    
    # 填您的密钥
    clientKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    
    # 填您自己的代理,不要填本地的地址
    proxy = "http://JN3wWChA:Dsg7ckfv@176.222.59.86:64048"
    proxies = {
        'http': proxy, 
        'https': proxy,
    }
    
    # 要访问的网址
    url = "https://nowsecure.nl"


    # 正常情况是这样的
    # response = requests.get(url, proxies=proxies)
    # print("请求响应:", response.status_code)
    # print("网页标题:", response.text[:200])
    # 返回:请求响应: 403


    # 使用 curl_cffi.requests请求
    # response = requests.get(url, proxies=proxies, impersonate="chrome110")
    # print("请求响应:", response.status_code)
    # print("网页标题:", response.text[:200])
    # 返回:请求响应: 200


    # 使用接口返回的值来请求
    task = get_result(url, proxy=proxy)
    if not task.get("solution"):
        print("任务失败", task)
        exit()
        
    solution = task.get("solution")
    headers = {
        'User-Agent': solution.get("user_agent")
    }
    print("Ua", headers)
    
    cookies = solution.get("cookies")
    print("Cookies:", cookies)
    
    response = requests.get(url, headers=headers, cookies=cookies, proxies=proxies, impersonate="chrome110")
    print("请求响应:", response.status_code)
    print("网页标题:", response.text[:200])