|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
根据网上查的使用功能requests库加上代理ip后去访问对应的网址,最后网站识别出来仍然是真实的IP地址,没有隐藏起来啊?
- import urllib.request
- import requests
- import re
- import os
- import random
- def url_open(url):
- proxy = {
- "http":"http://183.3.150.210:41258",
- "http":"http://115.223.77.54:8010"
- }
- header = {
- "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
- "accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
- "accept-encoding":"zh-CN,zh;q=0.9",
- "authority":"www.ip.cn"
- }
-
- response = requests.get(url,proxies =proxy,headers=header)
- return response.text
- def main(url):
- content = url_open(url)
- a = content.find('<div class="well"><p>')
- b = content.find("</div>",a)
-
- print(content[a:b])
-
- if __name__=="__main__":
- url = "https://www.ip.cn/"
- main(url)
复制代码
返回结果如下:
>>>
<div class="well"><p>您现在的 IP:<code>114.247.125.227</code></p><p>所在地理位置:<code>北京市 联通</code></p><p>GeoIP: Changping, Beijing, China</p>
>>>
<div class="well"><p>您现在的 IP:<code>114.247.125.227</code></p><p>所在地理位置:<code>北京市 联通</code></p><p>GeoIP: Changping, Beijing, China</p> |
|