分享一个获取代理ip的python函数
分享一个获取代理ip的python函数
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#coding:utf-8from bs4 import BeautifulSoupimport requestsimport randomdef getproxyip():headers = {'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8','Accept-Encoding':'gzip,deflate,sdch','Host':'www.ip-adress.com','User-Agent':'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0'}proxy_req = requests.get(proxy_url,headers=headers)proxy_soup = BeautifulSoup(proxy_req.text)proxy_ip = proxy_soup.find_all('tr',{'class':'yellow'})return proxy_ip[random.randrange(0,4)].td.text |
#/usr/local env python
#coding utf-8
import os
import urllib
from bs4 import BeautifulSoup
def log():
f=open("f:\daili.txt",'a')
f.write(ip)
f.close()
def fenxi():
page = urllib.urlopen(url)
data = page.read()
soup=BeautifulSoup(data)
#print soup
list=soup.find_all('span')
for i in list:
#print i.get_text()
global ip
ip= i.get_text()
s="\n".join(ip.split('#'))
print s
log()
for i in range(1,10):
if i==1:
url = 'http://www.youdaili.cn/Daili/http/556.html'
print url
fenxi()
else:
url = 'http://www.youdaili.cn/Daili/http/556_'+str(i)+'.html'
print url
fenxi()
运行结果:
||||||||IP知识库最新代理IPwww.Youdaili.Cn07-09免费代理国内外http代理ip地址1.186.200.211:8080@HTTP#印度
2.135.238.92:9090@HTTP#哈萨克斯坦
2.181.177.7:8080@HTTP#伊朗
2.183.155.2:8082@HTTP#伊朗
分享一个获取代理ip的python函数的更多相关文章
- Python学习笔记六(免费获取代理IP)
为获取网上免费代理IP,闲的无聊,整合了一下,免费从三个代理网站获取免费代理IP,目的是在某一代理网站被限制时,仍可从可以访问的其他网站上获取代理IP.亲测可用哦!^_^ 仅供大家参考,以下脚本可添 ...
- python编写的自动获取代理IP列表的爬虫-chinaboywg-ChinaUnix博客
python编写的自动获取代理IP列表的爬虫-chinaboywg-ChinaUnix博客 undefined Python多线程抓取代理服务器 | Linux运维笔记 undefined java如 ...
- python爬虫之反爬虫(随机user-agent,获取代理ip,检测代理ip可用性)
python爬虫之反爬虫(随机user-agent,获取代理ip,检测代理ip可用性) 目录 随机User-Agent 获取代理ip 检测代理ip可用性 随机User-Agent fake_usera ...
- Python3.x:获取代理ip以及使用
Python3.x:获取代理ip以及使用 python爬虫浏览器伪装 #导入urllib.request模块 import urllib.request #设置请求头 headers=("U ...
- 做了一个动态代理IP池项目,邀请大家免费测试~
现在出来创业了,目前公司在深圳. 做了啥呢, 做了一个动态代理 IP 池项目 现在邀请大家免费测试体验! 免费激活码:关注微信公众号:2808proxy (每人每天限领一次噢~) 网站:https:/ ...
- python爬虫实战(一)——实时获取代理ip
在爬虫学习的过程中,维护一个自己的代理池是非常重要的. 详情看代码: 1.运行环境 python3.x,需求库:bs4,requests 2.实时抓取西刺-国内高匿代理中前3页的代理ip(可根据需求自 ...
- python获取代理IP
利用requests库获取代理,用Beautiful库解析网页筛选ip # -*- coding: utf- -*- import requests from bs4 import Beautiful ...
- C#——做一个简单代理IP池
一.缘由. 抓取数据时,有一些网站 设置了一些反爬虫设置,进而将自己本地 IP 地址拉入系统黑名单.从而达到禁止本地 IP 访问数据的请求. 二.思路. 根据其他 代理 IP 网站,进行一个免费的代理 ...
- 分享一个刷网页PV的python小脚本
下面分享一个小脚本,用来刷网页PV. [root@huanqiu ~]# cat www.py #!/usr/bin/python# coding: UTF-8import webbrowser as ...
随机推荐
- The model used to open the store is incompatible with the one used to create the store
说什么数据不兼容,,,,这时删除模拟器的应用,,,重新启动测试.
- position relative和absolute区别
看这个博客 说的很详细http://blog.sina.com.cn/s/blog_647a022e0101b2gn.html 总的来说 这两个属性都是通过增加left和right偏离原来的位置 但 ...
- iframe,modaldialog父子窗口相互通信的问题
--- 子窗口访问父窗口的window对象 --- 打开新窗口一般有几种方法,window.open(...),window.showModalDialog(...),以及iframe中嵌套页面,另外 ...
- QT直接支持GB18030,附它对此编码的一堆相关文档描述
http://doc.qt.io/qt-5/qtextcodec.html http://doc.qt.io/qt-5/codec-gbk.html
- There is an error in invoking javac. A full JDK (not just JRE) is required
最近调整了磁盘分区,硬盘里什么都没有了,可惜了我很多项目还有数据库资源然后把以前ssh项目重新导入进来的时候出现了一个错误org.apache.jasper.JasperException: PWC6 ...
- paip.php-gtk 桌面程序 helloworld总结
paip.php-gtk 桌面程序 helloworld总结 作者Attilax , EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog.cs ...
- CentOS 64位上编译 Hadoop 2.6.0
Hadoop不提供64位编译好的版本号,仅仅能用源代码自行编译64位版本号. 学习一项技术从安装開始.学习hadoop要从编译開始. 1.操作系统编译环境 yum install cmake lzo- ...
- ceph操作相关命令整合
ceph基本操作: /etc/init.d/ceph -a start/stop //即在所有节点上执行 单个操作: start/stop ceph-osd id={id} start/stop ce ...
- Android学习笔记:ListView简单应用--显示文字列表
在activity中的编写如下代码: final List<String> items = new ArrayList<String>(); //设置要显示的数据,这里因为是例 ...
- Android 涂鸦最佳实践
Android中实现手势画图一般都两种方式,一是直接在View上绘制,而是使用SurfaceView. 两者还是有一些差别的.简介下. View:显示视图,内置画布,提供图形绘制函数.触屏事件.按键事 ...