分享一个获取代理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 ...
随机推荐
- GDB调试精粹及使用实例
一:列文件清单 1. List (gdb) list line1,line2 二:执行程序 要想运行准备调试的程序,可使用run命令,在它后面可以跟随发给该程序的任何参数,包括标准输入和标准输出说明符 ...
- poj 1200 Crazy Search(hash)
题目链接:http://poj.org/problem?id=1200 思路分析:从数据来看,该题目使用线性时间算法,可见子串的比较是不可能的:使用hash可以在常数时间内查找,可以常数时间内判重, ...
- Apache JMeter - load test tool
What is it? ->>>> http://jmeter.apache.org/index.html (Please read!) Where to get it? - ...
- 在UITouch事件中画圆圈-iOS8 Swift基础教程
这篇教程主要内容展示如何利用Core Graphics Framework画圆圈,当用户点击屏幕时随机生成不同大小的圆,这篇教程在Xcode6和iOS8下编译通过. 打开Xcode,新建项目选择Sin ...
- Linux下的定时器
以下摘自linux下的man文件:(man getitimer) #include <sys/time.h> int getitimer(int which, struct iti ...
- css中的@inport 与link
在html 代码中我们常常用分离的思想引入外部的css文件,常用的方法有2种,@import 语法: <style type="text/css" media="s ...
- PendingIntent.getBroadcast第四个参数flags
(1) android.app.PendingIntent.FLAG_UPDATE_CURRENT 如果PendingIntent已经存在,保留它并且只替换它的extra数据. (2) android ...
- (Problem 6)Sum square difference
Hence the difference between the sum of the squares of the first ten natural numbers and the square ...
- Apache ab 使用说明
第一章 简介 ab是Apache超文本传输协议(HTTP)的性能测试工具.其设计意图是描绘当前所安装的Apache的执行性能,主要是显示你安装的Apache每秒可以处理多少个请求. 第二章 说明 ab ...
- Codeforces Round #FF (Div. 2):C. DZY Loves Sequences
C. DZY Loves Sequences time limit per test 1 second memory limit per test 256 megabytes input standa ...