-
Notifications
You must be signed in to change notification settings - Fork 0
/
pc2.py
55 lines (44 loc) · 1.26 KB
/
pc2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding:utf-8 -*-
__author__='www.moonsec.com'
import os,sys
import urllib2
import threading
import Queue
q=Queue.Queue()
baidu_spider="Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"
lines=open("D:\python2.7\example\dir.txt",'r')
for line in lines:
line=line.rstrip()
q.put(line)
def scaner():
while not q.empty():
path=q.get()
url="%s%s" % (domain_name,path)
print path
headers={}
headers['User-Agent']=baidu_spider
requset=urllib2.Request(url,headers=headers)
try:
response = urllib2.urlopen(requset)
content=response.read()
if len(content):
print "Status [%s] - path: %s" % (response.code,url)
wx('sb.txt',url+'\n')
response.close()
except urllib2.HTTPError as e:
pass
def show():
print "scandir.py http://www.moonsec.com 10"
def wx(filename,context):
f= file(filename,"a+")
f.write(context)
f.close()
if __name__ == '__main__':
if len(sys.argv) < 3:
show()
sys.exit()
thread_num=sys.argv[2]
domain_name=sys.argv[1]
for i in range(int(sys.argv[2])):
t = threading.Thread(target=scaner)
t.start()