python获取代理IP
利用requests库获取代理,用Beautiful库解析网页筛选ip
# -*- coding: utf- -*-
import requests
from bs4 import BeautifulSoup
from threading import Thread headers = {'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0'} #定义获取IP函数
def get_ip():
#写入txt
write_ip = open('get_ip.txt', 'w')
for page in range(, ):
url = 'http://www.xicidaili.com/nn/%s' % page
r = requests.get(url, headers=headers,timeout=) # 用beautifulsoup库解析网页
soup = BeautifulSoup(r.content, 'lxml')
trs = soup.find('table', id='ip_list').find_all('tr') for tr in trs[:]:
tds = tr.find_all('td')
ip = tds[].text.strip()
port = tds[].text.strip()
write_ip.write('%s\n'%(ip+':'+port))
write_ip.close()
print('done') get_ip()
python获取代理IP的更多相关文章
- python获取代理IP并测试是否可用
# coding: utf-8 import urllib2 import re import time def getDL(page): url = 'http://www.xicidaili.co ...
- python编写的自动获取代理IP列表的爬虫-chinaboywg-ChinaUnix博客
python编写的自动获取代理IP列表的爬虫-chinaboywg-ChinaUnix博客 undefined Python多线程抓取代理服务器 | Linux运维笔记 undefined java如 ...
- 分享一个获取代理ip的python函数
分享一个获取代理ip的python函数 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #coding:utf-8 from bs4 import Beaut ...
- python爬虫之反爬虫(随机user-agent,获取代理ip,检测代理ip可用性)
python爬虫之反爬虫(随机user-agent,获取代理ip,检测代理ip可用性) 目录 随机User-Agent 获取代理ip 检测代理ip可用性 随机User-Agent fake_usera ...
- Python学习笔记六(免费获取代理IP)
为获取网上免费代理IP,闲的无聊,整合了一下,免费从三个代理网站获取免费代理IP,目的是在某一代理网站被限制时,仍可从可以访问的其他网站上获取代理IP.亲测可用哦!^_^ 仅供大家参考,以下脚本可添 ...
- Python3.x:获取代理ip以及使用
Python3.x:获取代理ip以及使用 python爬虫浏览器伪装 #导入urllib.request模块 import urllib.request #设置请求头 headers=("U ...
- python获取公网ip,本地ip及所在国家城市等相关信息收藏
python获取公网ip的几种方式 from urllib2 import urlopen my_ip = urlopen('http://ip.42.pl/raw').read() ...
- python获取公网ip的几种方式
python获取公网ip的几种方式 转 https://blog.csdn.net/conquerwave/article/details/77666226 from urllib2 import u ...
- python检验代理ip是否可用、代理ip检验
python检验代理ip是否可用.代理ip检验 安装相关模块: pip install requests 验证代理IP是否可用脚本: import random import telnetlib im ...
随机推荐
- arcgis 浅入
首先声明,此文只是用于学习,非商业用途!!20181226谷子弟留 有朋友需要用arcgis来学习分析图块,实现图块的分类和数据分析和统计. 于是网上找了找资源. http://pan.baidu ...
- git stash命令
命令:git stash 1.使用git stash 保存当前的工作现场, 那么就可以切换到其他分支进行工作,或者在当前分支上完成其他紧急的工作,比如修订一个bug测试提交. 2.如果一个使用了一个g ...
- 请问WCF 跟 WebService之间的相同跟异同
https://social.msdn.microsoft.com/Forums/zh-CN/c06420d1-69ba-4aa6-abe5-242e3213b68f/wcf-webservice W ...
- Asp.net博客系统收集和简单介绍
国内Asp.net博客系统收集和简单介绍 [转载文章,仅供个人参考,引自http://www.soyaoo.com/Blog/post/92.html] 1.ZJ-Blog程序简介:基于A ...
- Lab 6-2
Analyze the malware found in the file Lab06-02.exe. Questions and Short Answers What operation does ...
- Mac 上搭建基于 Hexo + GitHub 个人博客
环境配置 本人电脑系统:macOS Node.js 生成静态页面.安装Node.js Git 用于将本地 Hexo 内容提交到 Github.Xcode自带Git(前提:macOS已经安装了Xcode ...
- How-to: Use HBase Bulk Loading, and Why
How-to: Use HBase Bulk Loading, and Why http://blog.cloudera.com/blog/2013/09/how-to-use-hbase-bulk- ...
- Linux中安装Mysql授权远程访问
一.直接授权 mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OP ...
- 118. Pascal's Triangle (java)
问题描述: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5 ...
- 文件名简体转繁体bat
@echo off rem 指定文件夹路径 set "fd=D:\下载的图片" rem 0为转换文件名,1为转换文件夹名,2为同时转换文件名和文件夹名 set f=0 rem 0为 ...