-
Notifications
You must be signed in to change notification settings - Fork 0
/
spiderTools.py
executable file
·43 lines (36 loc) · 1.03 KB
/
spiderTools.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
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
import sys
from spiderqueue import HTTPSQSQueue
class spiderTools():
def __init__(self):
pass
def feed(self, qName, cFile):
'''
Feed HTTPSQSQueue with domains from cached file
'''
if not os.path.exists(cFile):
print 'File does not exists!'
return
f = open(cFile)
lines = f.readlines()
count = 0
for line in lines:
HTTPSQSQueue.put(qName,line.strip())
count = count + 1
f.close()
print HTTPSQSQueue.status(qName)
def reset(self, qName):
'''
reset a HTTPSQSQueue
'''
HTTPSQSQueue.reset(qName)
print HTTPSQSQueue.status(qName)
if __name__ == '__main__' :
reload(sys)
sys.setdefaultencoding("UTF-8")
if len(sys.argv) == 4 and sys.argv[1] == 'feed':
spiderTools().feed(sys.argv[2], sys.argv[3])
if len(sys.argv) == 3 and sys.argv[1] == 'reset':
spiderTools().reset(sys.argv[2])