#coding=utf-8
import sys
import requests
for i in range(3000,4999,1):
url = 'http://192.168.88.139:8888/20150602'+str(i)+'.html'
r = requests.get(url)
if r.status_code == 200:
print url
print r.content

原文

http://zone.wooyun.org/content/20885

多线程+文本逐行读取+URL的IP转换+写入

# -*-coding:utf-8-*-
import os
import sys
import Queue
import getopt
import logging
import requests
import threading
import time
import socket
print "start:" + (time.strftime("%H:%M:%S")) logging.basicConfig(
level=logging.WARNING,
format="[%(asctime)s] %(message)s"
) class BatchThreads(threading.Thread):
def __init__(self, queue):
super(BatchThreads, self).__init__()
self.queue = queue def run(self):
while True:
if self.queue.empty():
break
else:
tempurl = self.queue.get()
#print tempurl
try:
url = 'http://'+tempurl
#print url
r = requests.get(url, timeout=5)
if r.status_code == 200 :
print url+' '+'access-comman:200'
#print tempurl
ip = socket.gethostbyname(tempurl)
#print ip
yes = open('yes.txt','a')
yes.write(url+' ')
yes.write(' '+ip+'\n')
yes.close() except:
pass
print url+" error"
noaccess = open('noaccess.txt','a')
noaccess.write(url+'\n')
noaccess.close() def batch_queue(_queue, _thread_number):
with open('url-hz.txt') as f:
urls = [line.strip() for line in f.readlines()]
urls = set(filter(lambda url: url and not url.startswith("#"), urls))
if urls:
for url in urls:
queue.put(url)
if _thread_number > (queue.qsize() / 2):
_thread_number = (queue.qsize()) for _ in xrange(_thread_number):
threads.append(BatchThreads(_queue)) for t in threads:
t.start()
for t in threads:
t.join() threads = []
queue = Queue.Queue()
thread_number = 20
batch_queue(queue, thread_number) print"end:" + (time.strftime("%H:%M:%S"))

批量文本读取URL获取正常访问且保留对应IP的更多相关文章

  1. js进阶ajax读取json数据(ajax读取json和读取普通文本,和获取服务器返回数据(链接)都是一样的,在url处放上json文件的地址即可)

    js进阶ajax读取json数据(ajax读取json和读取普通文本,和获取服务器返回数据(链接)都是一样的,在url处放上json文件的地址即可) 一.总结 ajax读取json和读取普通文本,和获 ...

  2. java正则 读取html 获取标题/超链接/链接文本/内容

    java正则 读取html 获取标题/超链接/链接文本/内容 参考链接:http://yijianfengvip.blog.163.com/blog/static/175273432201142785 ...

  3. js javascript 获取url,获得当前页面的url,静态html文件js读取url参数

    获得当前页面的url window.location.href 静态html文件js读取url参数 location.search; //获取url中"?"符后的字串 下边为转载的 ...

  4. PHP 获取当前访问的完整URL

    代码如下: <?php // php 获取当前访问的完整url function GetCurUrl() { $url = 'http://'; if(isset($_SERVER['HTTPS ...

  5. Linux分析日志获取最多访问的前10个IP

    原文地址:http://xuqq999.blog.51cto.com/3357083/774714 apache日志分析可以获得很多有用的信息,现在来试试最基本的,获取最多访问的前10个IP地址及访问 ...

  6. linux分析apache日志获取最多访问的前10个IP

    apache日志分析可以获得很多有用的信息,现在来试试最基本的,获取最多访问的前10个IP地址及访问次数. 既然是统计,那么awk是必不可少的,好用而高效. 命令如下: awk '{a[$1] += ...

  7. 更改一个链接的文本、URL 以及 target

    <html> <head> <script type="text/javascript"> function changeLink() { do ...

  8. 根据URL获取图片

    背景:今天因为生产环境的系统界面图片无法显示被领导叼了一波,之前用Hutool工具类解析URL获取图片的,在生产环境上跑了一个多月都正常,嘣,今天突然发现周六下午后的图片统统显示异常,之后改为用jav ...

  9. Java从URL获取PDF内容

    Java直接URL获取PDF内容 题外话 网上很多Java通过pdf转 HTML,转文本的,可是通过URL直接获取PDF内容,缺没有,浪费时间,本人最近工作中刚好用到,花了时间整理下,分享出来,防止浪 ...

随机推荐

  1. 【转】CSS(10)盒子模型

    CSS中, Box Model叫盒子模型(或框模型),Box Model规定了元素框处理元素内容(element content).内边距(padding).边框(border) 和 外边距(marg ...

  2. Error executing aapt: Return code -1073741819

    在做andrid项目的时候,本来想把a项目中的a功能模块复制到b项目中,但是复制过程中出现xml文件id的问题, Error executing aapt: Return code -10737418 ...

  3. 1014 C语言文法

    <程序> -> <外部声明> | <程序> <外部声明> <外部声明> -> <函数定义> | <声明> ...

  4. 编写category时的便利宏(用于解决category方法从静态库中加载需要特别设置的问题)

    代码摘录自YYKit:https://github.com/ibireme/YYKit /** Add this macro before each category implementation, ...

  5. .NET 可空值类型

    Microsoft在CLR中引入了可空值类型(nullable value type)的概念. FCL中定义System.Nullable<T>类如下: [Serializable,Str ...

  6. [LeetCode]题解(python):092 Reverse Linked List II

    题目来源 https://leetcode.com/problems/reverse-linked-list-ii/ Reverse a linked list from position m to  ...

  7. [LeetCode]题解(python):074-Search a 2D Matrix

    题目来源 https://leetcode.com/problems/search-a-2d-matrix/ Write an efficient algorithm that searches fo ...

  8. ie无法下载 无法打开该internet站点.请求的站点不可用或无法找到.请稍后重试

    PK找的: http://support.microsoft.com/kb/316431/ 症状 ... 如果服务器使用着安全套接字层 (SSL) 并且已将下面的两个 HTTP 标头或其中的一个添加到 ...

  9. form和validate示例

    //验证from表单 $(function () { $("#addUserForm").validate({ rules: { txtName: { required: true ...

  10. Vue.2.0.5-模板语法

    Vue.js 使用了基于 HTML 的模版语法,允许开发者声明式地将 DOM 绑定至底层 Vue 实例的数据.所有 Vue.js 的模板都是合法的 HTML ,所以能被遵循规范的浏览器和 HTML 解 ...