马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import urllib.request
url = "https://ip.cn/index.php"
proxy_support = urllib.request.ProxyHandler({"http": '118.181.226.166:44640'})
opener = urllib.request.build_opener(proxy_support)
opener.addheaders =[('User-Agent','Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3970.5 Safari/537.36')]
urllib.request.install_opener(opener)
response = urllib.request.urlopen(url)
html = response.read().decode('utf-8')
print(html)
C:\Users\86152\AppData\Local\Programs\Python\Python37\python.exe C:/Users/86152/PycharmProjects/爬虫/demo5.py
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>IP.cn - IP 地址查询 | 地理位置 | 手机归属地</title>
<meta name="robots" content="all" />
<meta name="Keywords" content="ip,ip查询,手机ip,本机ip,外网ip,ip地址查询,手机号,归属地">
<meta name="Description" content="专业本机 IP 地址查询、手机 IP 地址、地理位置查询、IP 数据库、手机号归属地查询、电话号码黄页查询,可查广告、骚扰、快递、银行、保险、房地产、中介电话。">
<link href='css/bootstrap.min.css' rel='stylesheet' type='text/css'>
<meta name="viewport" content="width=device-width, minimum-scale=0.5">
<meta name="format-detection" content="telephone=no">
<!--[if lt IE 8]>
<script src="js/ie8.js"></script>
<![endif]-->
<script src="js/jq.js"></script>
<link href='css/main.css' rel='stylesheet' type='text/css'>
</head>
<body>
<div class="container-fluid">
<div class="header">
<a href="/"><img src="img/logo.gif"></a>
</div>
<div class="mainbar">
<ul class="nav nav-pills center-pills">
<li class="active"><a href="/">IP 查询</a></li>
<li><a href="/db">手机、电话号码数据库</a></li>
<li><a href="/dns.html">DNS</a></li>
<li><a href="/chnroutes.html">IP 列表</a></li>
</ul>
</div>
<div class="searchform">
<form name="fs" action="/" method="GET" class="form-search">
<input name="ip" type="text" placeholder="请输入要查询的 IP 地址" class="span3" autofocus>
<input id="s" type="submit" class="btn btn-primary" value="查询">
</form>
</div>
<div id="result"><div class="well"><p>您现在的 IP:<code>115.231.12.200</code></p><p>所在地理位置:<code>浙江省绍兴市 电信</code></p><p>GeoIP: <code>Beibei, Chongqing, China</code></p></div></div>
</div>
<div class="footer">
<p>©2006-2020 IP.cn 版权所有</p>
</div>
<script type="text/javascript" src="//w.cnzz.com/c.php?async=1&id=123770" async="async"></script>
</body>
</html>
Process finished with exit code 0
|