Skip to content

Commit 18ee2b0

Browse files
committed
Scraper reads now EOF.
1 parent d501ea7 commit 18ee2b0

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

scraper.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
####################################################################################
55
#
66
# Basicly same idea as Passcracker.py, only this generates a baseword list.
7-
# Only reads 1MB from password.txt and choose a random word to search for.
7+
# Reads 1MB from password.txt and choose a random word to search for.
88
#
99
####################################################################################
1010

@@ -15,15 +15,16 @@
1515
import random
1616
import subprocess
1717
import unicodedata
18-
import os
18+
import time
1919

2020
def unique(words):
2121
array = []
2222
[array.append(x.encode('utf-8')) for x in words if x not in array and (len(x) > 3 and len(x) < 16)]
2323
return array
2424

2525
def twitter(query):
26-
data = json.loads(urllib2.urlopen("http://search.twitter.com/search.json?q=%s&rpp=1000"%query).read())
26+
twitter = urllib2.urlopen("http://search.twitter.com/search.json?q=%s&rpp=1000"%query).read()
27+
data = json.loads(twitter)
2728
array = []
2829

2930
for tweet in data['results']:
@@ -33,21 +34,25 @@ def twitter(query):
3334
return array
3435

3536
def randomword():
36-
readfile = os.open('password.txt', os.O_RDONLY)
37-
words = random.choice(filter(None, [line.strip() for line in os.read(readfile, 100000).split('\n')]))
37+
f= open('password.txt', "r")
38+
f.seek (0, 2)
39+
size = f.tell()
40+
f.seek (max (size-1024, 0), 0)
41+
words = random.choice(filter(None, [line.strip() for line in f.readlines()]))
42+
3843
return words
3944

4045
if __name__ == "__main__":
4146

4247
while 1:
4348
try:
4449
word = randomword()
45-
print "\nSearching for:",word
50+
print "Searching for:",word
4651
wordlist = unique(twitter(word))
47-
print wordlist
48-
52+
4953
for i in xrange(len(wordlist)):
5054
open("password.txt", "a").write("%s\n"%wordlist[i])
55+
time.sleep(1)
5156

5257
except (KeyboardInterrupt, SystemExit):
5358
sys.exit(sys.stderr.write("Bai Bai\n"))

0 commit comments

Comments
 (0)