当前位置: 首页 > news >正文

建设项目环评验收网站微信营销软件有哪些

建设项目环评验收网站,微信营销软件有哪些,安丘营销型网站建设,网页设计学校官网问题 有很多时候,我们在用代理IP,搞搞测试,不过很多时候我们都在这么使用,而不知道,到底代理成功没? 注意: http 只能代理是 http 的网址,https 只能代理是 https 的网址 网上有很…

问题

有很多时候,我们在用代理IP,搞搞测试,不过很多时候我们都在这么使用,而不知道,到底代理成功没?

注意:
http 只能代理是 http 的网址,https 只能代理是 https 的网址

网上有很多python代理的方法,大部分在代理中写了很多IP,有的还把https页写到里面,我不知道他们后面代码是否添加了判断http还是https网址,代理网址协议不同是不能代理成功的。

本人推荐这么写,只写单个代理,换的时候只需要找到主要信息,拼接出这个格式即可。因为把 http 和 https 分开能够直接访问使用不同协议的网址,方便(那种通用代理IP,既能 http,也能 https的也建议分开)

http_proxies = {"http": "http://114.139.35.220:8118"}
https_proxies = {"https": "https://114.239.254.228:9999"}

环境

编译IDA:pycharm 社区版
python版本:python3.7.4
用到的库:requests、re

第一种方法

最简单的判断是否代理成功,当然是直接使用,是否能够访问同协议网址,能够访问就能使用,反之则不能使用。

测试IP是否可以使用
http:    http://www.haoshiwen.org/
https:   https://www.gushiwen.org/

这个只测了一次,如果想要准确可以循环多测几次,没有设置时间,只要能够访问就可以用,没追求响应时间。(失败会消耗很多时间,一般建议设置超时 timeout=5~10 就好了)

class TestIP:"""测试IP是否可以使用http:    http://www.haoshiwen.org/https:   https://www.gushiwen.org/"""@staticmethoddef http(proxies):"""http://www.haoshiwen.org/@param proxies: 代理 http@return:        True/False"""url = "http://www.haoshiwen.org/"headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0","Connection": "close"}try:res = requests.get(url, headers=headers, proxies=proxies)if res.status_code == 200:print("代理成功")return Trueexcept Exception:print("代理失败")return False@staticmethoddef https(proxies):"""https://www.gushiwen.org/@param proxies: 代理 https@return:        True/False"""url = "https://www.gushiwen.org/"headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0","Connection": "close"}try:res = requests.get(url, headers=headers, proxies=proxies)if res.status_code == 200:print("代理成功")return Trueexcept Exception:print("代理失败")return False

在这里插入图片描述
可以看到有些可以使用,而有的不能使用。

第二种方法

如果上面哪一种你还是不放心,就是想知道 IP 是否真正地被替换了,可以通过访问 IP 查询网站,判断是否替换了 IP。

检查IP是否更换成功
http:    http://ip.tool.chinaz.com/
https:   https://ipip.net/ip/

这两个是国内比较简洁、高效的 IP 查询网站了。

这个只测了一次,如果想要准确可以循环多测几次,没有设置时间,只要能够访问就可以用,没追求响应时间。(失败会消耗很多时间,一般建议设置超时 timeout=5~10 就好了)

class CheckIP:"""检查IP是否更换成功http:    http://ip.tool.chinaz.com/https:   https://ipip.net/ip/"""@staticmethoddef MyIP():"""https://ipip.net/@return: 自己的 IP"""url = "https://ipip.net/ip/"headers = {"Host": "www.ipip.net","Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0","Connection": "close"}res = requests.get(url, headers=headers)ip_pat = '<input type="text" name="ip" value="(.*?)"'ip = re.findall(ip_pat, res.text)print(str(ip) + "\tMyIP")return ip@staticmethoddef Http(proxies):"""http://ip.tool.chinaz.com/@param proxies: 代理 http@return:        True/False"""url = "http://ip.tool.chinaz.com/"headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0","Connection": "close"}try:res = requests.get(url, headers=headers, proxies=proxies)if res.status_code == 200:ip_pat = '<dd class="fz24">(.*?)</dd>'ip = re.findall(ip_pat, res.text)print(str(ip) + "\t代理成功")return Trueexcept Exception:print("代理失败")return False@staticmethoddef Https(proxies):"""https://ipip.net/@param proxies: 代理 https@return:        True/False"""url = "https://ipip.net/ip/"headers = {"Host": "www.ipip.net","Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0","Connection": "close"}try:res = requests.get(url, headers=headers, proxies=proxies)if res.status_code == 200:ip_pat = '<input type="text" name="ip" value="(.*?)"'ip = re.findall(ip_pat, res.text)print(str(ip) + "\t代理成功")return Trueexcept Exception:print("代理失败")return False

在这里插入图片描述
这样就会放心多了吧。

总结

1、http 只能代理是 http 的网址,https 只能代理是 https 的网址。
2、如果用 http 代理 https,其实使用的还是自己的 IP(ipip.net 测试);https 则不能代理 http。
3、免费代理可用的很少(或则几乎不可用),玩玩就好了,费心费力效果不大。

几个还在更新的免费代理

IP海			http://www.iphai.com/free/ng
快代理			https://www.kuaidaili.com/free/
云代理			http://www.ip3366.net/free/
免费代理			http://ip.jiangxianli.com/			# http 最好
西刺代理			https://www.xicidaili.com/			# 综合最好
西拉代理			http://www.xiladaili.com/
齐云代理			http://www.qydaili.com/free/
66免费代理		http://www.66ip.cn/					# 没标明 http/https,但可免费提取 http
89免费代理		http://www.89ip.cn/					# 没标明 http/https 没多大用处

剩余代码

# -*- coding: utf-8 -*-
# @Time : 2019/10/14 22:21
# @Author : ljf
# @File : testIP.py
import requests
import reif __name__ == "__main__":http_proxies = {"http": "http://60.173.241.77:8060"}https_proxies = {"https": "https://117.69.200.180:9999"}# TestIP.http(http_proxies)# TestIP.https(https_proxies)CheckIP.MyIP()CheckIP.Http(http_proxies)CheckIP.Https(https_proxies)
http://www.lbrq.cn/news/2793493.html

相关文章:

  • 东莞城乡建设网站爱站小工具计算器
  • 广州知名网站建设淘宝如何提升关键词排名
  • 无锡做网站哪里好站长权重
  • 长沙网页制作网站南阳seo
  • 网店装修网站英语seo
  • 网站建设公司net2006游戏如何在网上推广
  • 政务网站建设规划收录优美图片topit
  • 高端公司网站刷网站软件
  • 企业做网站的费用免费的关键词挖掘工具
  • 深圳有什么做招聘网站的公司吗seo sem优化
  • 建设网站直接委托单位免费建站软件
  • 百度云做网站空间百度指数api
  • 动态网站开发视频教程百度助手应用商店下载安装
  • 做网站530元广州seo营销培训
  • 网站建设php怎么安装关键词歌词任然
  • 简易的网站百度竞价排名一年费用
  • 合肥知名网站制作公司短视频询盘获客系统
  • 代写网站h5下一页
  • 网站开发语言 微信接口百度推广渠道商
  • 平板电脑可以做淘宝网站吗平台连接
  • 承德网站建设规划私人做网站的流程
  • 网站内搜索功能怎么做前端性能优化有哪些方法
  • 一个公司做两个网站的好处百度预测大数据官网
  • 龙岗网站制作公司一般多少钱快速优化关键词排名
  • 江苏专业的网站建设在哪个网站可以免费做广告
  • wordpress模板 淘宝客googleseo推广
  • dw如何制作自己的网站百度网址大全在哪里找
  • 做网站需要的流程发免费广告电话号码
  • dwcs5怎么做网站深圳外贸seo
  • 网站asp竞价推广什么意思
  • 两台电脑之间如何传输大文件?
  • Jmeter接口测试之文件上传
  • 深入解析RAGFlow六阶段架构
  • 云计算学习100天-第26天
  • 安装DDNS-go
  • 第4章 React状态管理基础