分享一个获取代理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 ...
随机推荐
- Ubuntu中文输入法
这里是Ubuntu12.04,刚把系统语言设成英文,发现输入法没有了. 看看下面是如何找回来的吧. Ubuntu上的输入法主要有小小输入平台(支持拼音/二笔/五笔等),Fcitx,Ibus,Scim等 ...
- 转:触屏中的js事件
一.触摸事件 ontouchstartontouchmoveontouchendontouchcancel 目前移动端浏览器均支持这4个触摸事件,包括IE.由于触屏也支持MouseEvent,因此他们 ...
- ARPU_百度百科
ARPU_百度百科 ARPU
- 文件队列 QueueFile
/** * Copyright (C) 2010 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the " ...
- LeetCode——Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given su ...
- SQL常用语句集合(不断更新)
1.多条件 查询 上下级 所有数据 select * from OrgUnit where (ParentId = '3' or OrgId='3' or ParentId in (select Or ...
- ARM流水线(pipeline)
- U+00A0 (Non-breaking space)无法被正确压缩
Code Glyph Decimal HTML Description #U+00A0 Non-breaking space 0096 https://zh.wikipedia.org/wik ...
- CPU满格的元凶,这回是由于QTimer引起的(默认interval是0,太猛)
timer_space = new QTimer(); qDebug() << SystemGlobal::m_app->SpaceUse; qDebug() << ti ...
- 基于 JVMTI 实现 Java 线程的监控(转)
随着多核 CPU 的日益普及,越来越多的 Java 应用程序使用多线程并行计算来充分发挥整个系统的性能.多线程的使用也给应用程序开发人员带来了巨大的挑战,不正确地使用多线程可能造成线程死锁或资源竞争, ...