#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. Eclipse下使用Ant 【转】

    官方在线帮助文档:http://ant.apache.org/manual/index.html 中文汉化 帮助文档:http://www.cnblogs.com/pengxl/archive/201 ...

  2. SVM神经网络的术语理解

    SVM(Support Vector Machine)翻译成中文是支持向量机, 这里的“机(machine,机器)”实际上是一个算法.而支持向量则是指那些在间隔区边缘的训练样本点[1]. 当初看到这个 ...

  3. 利用sqlserver日志恢复数据

    如果你已经急的焦头烂额,看到这篇文章的时候,请你换个坐姿,深呼吸几次,静下心来将这篇文章读完,也许你的问题迎刃而解. 我遇 到的情况是这样的,网站被植入木马,盗取了我的web.config文件,web ...

  4. Self和Super的用法

    self 是类的隐藏的参数,指向当前当前调用方法的类,另一个隐藏参数是 _cmd,代表当前类方法的 selector.这里只关注这个 self.super 是个啥?super 并不是隐藏的参数,它只是 ...

  5. LinQ总结

    不管是在Mvc还是在别的架构中的项目LinQ和Lambda总是经常会遇到的. 而有些LinQ的语法并不是很长用(我大部分用的是Lambda),所以有必要记录一下万一用到的时候我能很方便的找到我想找到的 ...

  6. FastDFS分布式文件系统安装与使用(单节点)

    http://blog.csdn.net/xyang81/article/details/52837974 http://download.csdn.net/detail/xyang81/966749 ...

  7. Provisioning Profile

    什么是Provisioning Profile? 从字面翻译,Provisioning Profile就是配置文件的意思,它在开发者账号体系中所扮演的角色也是配置和验证的作用.如果你有开发者账号,可以 ...

  8. java 发送http json请求

    public void getRemoteId(HttpServletRequest request,Model model){ String name = request.getParameter( ...

  9. imx6 mac地址设置

    imx6的mac地址总是固定的值,所以需要更改,采用的方法是在uboot中设置环境变量,之后在kernel中使用uboot中设置的mac地址的值.本文记录更改的过程. 参考链接: http://www ...

  10. SVN Working Copy locked ,并且进行clean up也还是不行

    标题:working copy locked 提示:your working copy appears to be locked. run cleanup to amend the situation ...