-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbcs.py
More file actions
104 lines (71 loc) · 2.46 KB
/
bcs.py
File metadata and controls
104 lines (71 loc) · 2.46 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import re
import sys
import json
import signal
import requests
import cssutils
import threading
from cssutils import css
from BeautifulSoup import BeautifulSoup
def signal_handler(signal, frame):
global page
sys.stdout.write("Finished on page: %d\n" % page)
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
class WalletThread(threading.Thread):
def __init__(self, url):
self.url = url
threading.Thread.__init__ (self)
def run(self):
global processes
processes += 1
subreq = requests.get(self.url)
if str(subreq.status_code) == '200':
balance = BeautifulSoup(subreq.text).find('td', id = 'final_balance')
value = float(balance.text.strip('BTC'))
if value > 0:
with open('./wallets_balance', 'a') as wallets_file:
wallets_file.write(
balance.text + '; ' + self.url + "\n"
)
processes -= 1
page = 0
try:
with open ('./page', 'r') as f:
page = int(f.read().strip())
except IOError: pass
except ValueError: pass
url = 'http://directory.io/'
status = None
processes = 0
while status != '404':
page += 1
sys.stdout.write("\rPage: %d, processes runned: %d" % (page, processes))
sys.stdout.flush()
req = requests.post(url + str(page))
if str(req.status_code) != '404':
wallet_key = None
wallet_rsa = None
wallet_url = None
soup = BeautifulSoup(req.text)
keys = soup.find('pre', {'class' : 'keys'})
for strong in keys.findAll('strong'):
strong.decompose()
for wallet in str(keys).split("\n"):
w_soup = BeautifulSoup(wallet)
for plus in w_soup.findAll('a', href = re.compile(r'warning')):
plus.decompose()
for block in w_soup:
if type(block).__name__ == 'NavigableString':
wallet_rsa = block.string.strip()
if type(block).__name__ == 'Tag':
wallet_url = block.get('href')
wallet_key = block.text
with open('./wallets', 'a') as wallets_file:
wallets_file.write(
str(wallet_key) + '; ' + str(wallet_rsa) + '; ' + str(wallet_url) + "\n"
)
if wallet_url:
WalletThread(str(wallet_url)).start()
with open('./page', 'w') as f:
f.write(str(page))