2021-09-07 09:35:02 -07:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
2021-09-06 16:30:12 -07:00
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
|
import requests
|
|
|
|
|
import sys
|
|
|
|
|
|
2021-09-06 17:36:48 -07:00
|
|
|
# check to see if we have input
|
|
|
|
|
if len(sys.argv) <= 1:
|
|
|
|
|
print()
|
2021-09-07 09:35:24 -07:00
|
|
|
print('Usage: distributednet-stats.py <user@domain.tld>')
|
2021-09-06 17:36:48 -07:00
|
|
|
print()
|
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
|
|
# distributed.net project search form
|
2021-09-06 16:30:12 -07:00
|
|
|
dnet_url = 'https://stats.distributed.net/participant/psearch.php'
|
|
|
|
|
|
2021-09-06 17:36:48 -07:00
|
|
|
### distributed.net projects ###
|
2021-09-06 16:30:12 -07:00
|
|
|
#dnet_project_id = 24 # OGR-24 Optimal Golomb Rulers
|
|
|
|
|
#dnet_project_id = 25 # OGR-25 Optimal Golomb Rulers
|
|
|
|
|
#dnet_project_id = 26 # OGR-26 Optimal Golomb Rulers
|
|
|
|
|
#dnet_project_id = 27 # OGR-27 Optimal Golomb Rulers
|
|
|
|
|
#dnet_project_id = 28 # OGR-28 Optimal Golomb Rulers
|
|
|
|
|
#dnet_project_id = 3 # RSA Labs' 56bit RC5 Encryption Challenge
|
|
|
|
|
#dnet_project_id = 5 # RSA Labs' 64bit RC5 Encryption Challenge
|
|
|
|
|
dnet_project_id = 8 # RSA Labs' 72bit RC5 Encryption Challenge
|
|
|
|
|
|
2021-09-06 17:36:48 -07:00
|
|
|
dnet_search_text = str(sys.argv[1]) # store the user argument into a variable
|
|
|
|
|
data = {'project_id':dnet_project_id,'st':dnet_search_text} # along with the project id
|
|
|
|
|
response = requests.post(dnet_url,data=data) # perfom a form post and get the response
|
2021-09-06 16:30:12 -07:00
|
|
|
|
2021-09-06 17:36:48 -07:00
|
|
|
if response: # if we received a response
|
|
|
|
|
soup = BeautifulSoup(response.text, 'lxml') # load the response into BeautifulSoup
|
2021-09-06 16:30:12 -07:00
|
|
|
|
|
|
|
|
print()
|
2021-09-06 17:36:48 -07:00
|
|
|
summary = soup.find('td',class_='htitle').text.lstrip() # find summary
|
2021-09-06 16:30:12 -07:00
|
|
|
|
|
|
|
|
if "Summary" in summary:
|
2021-09-06 17:36:48 -07:00
|
|
|
print('User: ' + dnet_search_text) # print user
|
|
|
|
|
summary = " ".join(summary.split()) # remove extra spaces from summary
|
|
|
|
|
summary = summary.split('/') # split summary and project into 2 strings
|
|
|
|
|
project = summary[0] # store the project name from the summary into a variable
|
|
|
|
|
print('Project: ' + project) # print project
|
2021-09-06 16:30:12 -07:00
|
|
|
else:
|
2021-09-06 17:36:48 -07:00
|
|
|
print(dnet_search_text + ' not found.') # notify if user not found
|
2021-09-06 16:30:12 -07:00
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
line = 0
|
2021-09-06 17:36:48 -07:00
|
|
|
for match in soup.find_all('td',align='right'): # search soup for table data
|
2021-09-06 16:30:12 -07:00
|
|
|
line +=1
|
2021-09-06 17:36:48 -07:00
|
|
|
if line == 1: # print overall rank
|
2021-09-06 16:30:12 -07:00
|
|
|
overall_rank = match.text.lstrip()
|
|
|
|
|
if overall_rank[0] != "T" and overall_rank[0] != "0":
|
2021-09-06 17:02:31 -07:00
|
|
|
overall_rank = overall_rank.split('(')
|
|
|
|
|
overall_rank = overall_rank[0]
|
2021-09-06 16:30:12 -07:00
|
|
|
print ("Overall Rank: " + overall_rank)
|
2021-09-06 17:36:48 -07:00
|
|
|
if line == 2: # print current rank
|
2021-09-06 16:30:12 -07:00
|
|
|
current_rank = match.text.lstrip()
|
|
|
|
|
if current_rank[0] != "0":
|
2021-09-06 17:02:31 -07:00
|
|
|
current_rank = current_rank.split('(')
|
|
|
|
|
current_rank = current_rank[0]
|
2021-09-06 16:30:12 -07:00
|
|
|
print ("Current Rank: " + current_rank)
|
2021-09-06 17:36:48 -07:00
|
|
|
if line == 3: # stop searching soup
|
2021-09-06 16:30:12 -07:00
|
|
|
print()
|
|
|
|
|
break
|
|
|
|
|
else:
|
2021-09-06 17:02:31 -07:00
|
|
|
print('An error has occured.')
|