注册 登录
编程论坛 Python论坛

requests 更换IP哪里错了?

Z89 发布于 2023-03-25 21:25, 156 次点击
程序代码:

import requests   
ua ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240'
s = requests.Session()
proxies = {'http': '219.100.37.219:433',
           'https': '219.100.37.219:433'}
r = s.get('http://',proxies=proxies)
print(r.text)
只有本站会员才能查看附件,请 登录


[此贴子已经被作者于2023-3-25 21:26编辑过]

6 回复
#2
东海ECS2023-03-25 21:51
这个图片是什么意思
是结果出错了还是发生了异常?
#3
Z892023-03-25 22:17
回复 2楼 东海ECS
图片是我网上抓到的数据,我的程序代码这样设置有错吗?

执行程序后找不到我设置的ip

[此贴子已经被作者于2023-3-25 22:19编辑过]

#4
东海ECS2023-03-26 10:40
print出了图片?不可能吧
#5
东海ECS2023-03-26 10:43
get加上heads = ua
#6
Z892023-05-16 14:34
程序代码:
import requests
import random
import time

http_ip = [
'146.190.242.193:8080',
'159.223.120.149:8080',
]


for i in range(10):
    try:
        ip_proxy = random.choice(http_ip)
        proxy_ip = {
            'http': ip_proxy,
            'https': ip_proxy,
        }
        print('使用代理的IP:', proxy_ip)
        response = requests.get("http://", proxies=proxy_ip)
        print(response.text)   
        print(response.status_code)         
        print(response)        
        print('当前IP有效')
        time.sleep(2)
    except Exception as e:
        print(e.args[0])
        print('当前IP无效')
        continue
#7
wp2319572023-05-16 14:54
回复 6楼 Z89
好多免费代理ip  都是无法使用的
1