|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import urllib.request
url = 'http://www.whatismyip.com.tw'
proxy_support = urllib.request.ProxyHandler({'http':'115.223.7.110:80'})
opener = urllib.request.build_opener(proxy_support)
urllib.request.install_opener(opener)
respones = urllib.request.urlopen(url)
html = respones.read().decode('utf-8')
print(html)
本帖最后由 Twilight6 于 2020-6-28 17:13 编辑
网站问题。 你拿自己的浏览器去访问都发现访问不了
换 url 就可以了 : http://httpbin.org/get 这个查 IP 在 origin 属性那可以看到 IP地址
改成这个:
- import urllib.request
- url = 'http://httpbin.org/get'
- proxy_support = urllib.request.ProxyHandler({'http':'115.223.7.110:80'})
- opener = urllib.request.build_opener(proxy_support)
- urllib.request.install_opener(opener)
- respones = urllib.request.urlopen(url)
- html = respones.read().decode('utf-8')
- print(html)
复制代码
运行结果(红框内是 IP 地址):
|
|