花生Http对接demo

本文介绍了如何使用Python的requests库通过代理服务器获取ChatgptAPI的数据,包括设置代理、发送请求以及处理响应状态。作者还提到了一系列关于爬虫项目的实战案例和相关资源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

import requests

url = "https://mobile.huashengdaili.com/servers.php"
params = {
    "session": "Uddc8--f0fb1018f6",
    "time": "1",
    "count": "1",
    "type": "json",
    "only": "1",
    "pw": "no",
    "protocol": "http",
    "separator": "1",
    "ip_type": "tunnel",
    "format": "city,time",
    "dev": "web"
}

response = requests.get(url, params=params)

if response.status_code == 200:
    data = response.json()
    if data["status"] == "0" and "list" in data and len(data["list"]) > 0:
        server_info = data["list"][0]
        server = server_info.get("sever")
        port = server_info.get("port")
        print("Server:", server)
        print("Port:", port)
    else:
        print("Error: Unable to retrieve server information.")
else:
    print("Error: Unable to connect to the API.")



# 获取到的代理IP地址和端口
proxy_server = str(server)
proxy_port = str(port)

# 新的接口URL
new_url = "https://cloud.taila.club"

# 设置代理
proxies = {
    "http": f"http://{proxy_server}:{proxy_port}",
    "https": f"http://{proxy_server}:{proxy_port}"
}

# 发起请求
response = requests.get(new_url, proxies=proxies)

# 处理响应
if response.status_code == 200:
    # 处理成功响应
    print("New request successful")
    print(response.text)
else:
    # 处理失败响应
    print("New request failed")

使用发方法:更改密钥即可

最后

🚀Python爬虫项目实战系列文章!!
⭐⭐欢迎订阅⭐⭐

【Python爬虫项目实战一】获取Chatgpt3.5免费接口文末付代码(过Authorization认证)
【Python爬虫项目实战二】Chatgpt还原验证算法-解密某宝伪知网数据接口

⭐⭐欢迎订阅⭐⭐
《记一次云之家签到抓包》
《记一次视频抓包m3u8解密过程》
《抓包部分软件时无网络+过代理检测 解决办法 安卓黄鸟httpcanary+vmos》
《Python】记录抓包分析自动领取芝麻HTTP每日免费IP(成品+教程)》
《某课抓包视频 安卓手机:黄鸟+某课app+VirtualXposed虚拟框架》

推荐专栏:

《Python爬虫脚本项目实战》

该专栏往期文章:
《【Python爬虫项目实战一】获取Chatgpt3.5免费接口文末付代码(过Authorization认证)》

如果您对爬虫感兴趣请收藏或者订阅该专栏哦《Python爬虫脚本项目实战》,如果你有项目欢迎联系我,我会同步教程到本专栏!
在这里插入图片描述

Python爬虫脚本项目实战
在这里插入图片描述

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

园游会永不打烊.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值