Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1095767
  • 博文数量: 187
  • 博客积分: 1156
  • 博客等级: 少尉
  • 技术积分: 2163
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-16 15:01
个人简介

go!go!go!

文章分类

全部博文(187)

文章存档

2024年(1)

2023年(11)

2022年(13)

2021年(15)

2020年(38)

2019年(3)

2018年(6)

2016年(1)

2015年(16)

2014年(13)

2013年(24)

2012年(46)

分类: Python/Ruby

2013-01-23 19:44:51

功能: 将一个filelist.conf中的url取出来,用多线程并行下载,将结果重定向到/dev/null


#!/usr/bin/python
import urllib,os,threading

proxies={'http': ''}
def processLine(line):
	print "child:",line
	while True:
		fin = urllib.urlopen(line,proxies=proxies)
		while True:
			fout=open('/dev/null', 'w')
			fout.write(fin.read(1024))

fileListName = '/tmp/filelist.conf'

fileListFile = open( fileListName )
fileNames = fileListFile.readlines()
fileListFile.close()

for fileName in fileNames:
	if fileName[-1] == '\\n':
		fileName = fileName[0:-1]
		print "Father:",fileName
		processThread = threading.Thread(target=processLine, args=[fileName])
		processThread.daemon = True
		processThread.start()




阅读(1397) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~