-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored main branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| titlePrinter() | ||
| check = rootcheck() | ||
| masterList = [] | ||
| blacklist = ('http://76qugh5bey5gum7l.onion') | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
| while len(inputList) > 0: | ||
| if not os.path.exists("../output/deepminer.db"): | ||
| deepminerDB = createDB() | ||
|
|
@@ -21,7 +22,6 @@ | |
| url = random.choice(inputList) | ||
| torstatus() | ||
| extensions = ('.jpg', 'jpeg', '.mp4', '.png', '.gif') | ||
| blacklist = ('http://76qugh5bey5gum7l.onion') | ||
| if url not in masterList and not url.endswith(extensions) and not url.startswith(blacklist): | ||
| print(Y +""" | ||
| [GRIME] New Iteration:""") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,8 +22,13 @@ def onionHTML(url): | |
| proxy = httplib2.ProxyInfo(proxy_type=socks.PROXY_TYPE_SOCKS5, proxy_host='localhost', proxy_port=9050) | ||
| http = httplib2.Http(proxy_info=proxy, timeout=30) | ||
| content = http.request(url, headers={'Connection': 'close', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36'})[1] | ||
| html = str(content,'utf-8').replace('\t',' ').replace('\n',' ').replace('\r',' ').replace('\"','') | ||
| return html | ||
| return ( | ||
| str(content, 'utf-8') | ||
| .replace('\t', ' ') | ||
| .replace('\n', ' ') | ||
| .replace('\r', ' ') | ||
| .replace('\"', '') | ||
| ) | ||
|
Comment on lines
-25
to
+31
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| except: | ||
| return "None" | ||
|
|
||
|
|
@@ -56,12 +61,9 @@ def ahmia(): | |
| for matchNum, match in enumerate(matches, start=1): | ||
| url = (match.group()) | ||
| results.append(url) | ||
| ahmia = list(set(results)) | ||
| return ahmia | ||
| return list(set(results)) | ||
|
Comment on lines
-59
to
+64
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def redditOnions(): | ||
| results = [] | ||
| regex = r"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.onion\/?[-a-zA-Z0-9@:%._\/+~#=]{1,256}" | ||
|
Comment on lines
-63
to
-64
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| url = "https://www.reddit.com/r/onions/new.json?limit=10000000000000000000000000000000" | ||
| req = request.Request(url, data=None, headers={'Connection': 'close', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36'}) | ||
|
|
||
|
|
@@ -72,12 +74,13 @@ def redditOnions(): | |
| if "Traceback (most recent call last):" in dataString: | ||
| redditOnions() | ||
| else: | ||
| regex = r"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.onion\/?[-a-zA-Z0-9@:%._\/+~#=]{1,256}" | ||
| matches = re.finditer(regex, dataString, re.MULTILINE) | ||
| results = [] | ||
| for matchNum, match in enumerate(matches, start=1): | ||
| url = (match.group()) | ||
| results.append(url) | ||
| reddit = list(set(results)) | ||
| return reddit | ||
| return list(set(results)) | ||
|
|
||
| def torstatus(): | ||
| torstatus = subprocess.getoutput("Service Tor Status | grep Active") | ||
|
|
@@ -104,7 +107,7 @@ def urlSplitter(url): | |
| directory = str(url.split(".org")[1]) | ||
| url = str(url.split(".org")[0]) + ".org" | ||
| else: | ||
| print(Y +"Unknown URL " + str(url)) | ||
| print(f"{Y}Unknown URL {str(url)}") | ||
|
Comment on lines
-107
to
+110
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| exit() | ||
| if directory == "": | ||
| directory = "/" | ||
|
|
@@ -116,8 +119,7 @@ def urlSplitter(url): | |
|
|
||
|
|
||
| def removeDuplicates(listOne, listTwo): | ||
| results = listOne + list(set(listTwo) - set(listOne)) | ||
| return results | ||
| return listOne + list(set(listTwo) - set(listOne)) | ||
|
Comment on lines
-119
to
+122
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def aTag(inputURL,html): | ||
| if inputURL[-1] == "/": | ||
|
|
@@ -129,25 +131,21 @@ def aTag(inputURL,html): | |
| url = (match.group()) | ||
| results.append(url) | ||
| onions = list(set(results)) | ||
| for i in onions: | ||
| temp.append((i.replace("<a href=","").replace(">",""))) | ||
| temp.extend(i.replace("<a href=","").replace(">","") for i in onions) | ||
| for i in temp: | ||
| if "http" in i: | ||
| if ".onion" not in i: | ||
| pass | ||
| else: | ||
| if ".onion" in i: | ||
| temp2.append(i) | ||
| elif "mailto:" in i: | ||
| pass | ||
| elif i.startswith("../"): | ||
| i = i.replace("../",inputURL+"/") | ||
| i = i.replace("../", f"{inputURL}/") | ||
| temp2.append(i) | ||
| elif i.startswith("/"): | ||
| temp2.append(inputURL+i) | ||
| else: | ||
| temp2.append(inputURL + "/" + i) | ||
| aTag = list(set(temp2)) | ||
| return aTag | ||
| temp2.append(f"{inputURL}/{i}") | ||
| return list(set(temp2)) | ||
|
Comment on lines
-132
to
+148
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def inputAdder(newInput, input): | ||
| for i in input: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,12 +2,10 @@ | |
| import sqlite3 | ||
|
|
||
| def createDB(): | ||
| con = sqlite3.connect('output/deepminer.db') | ||
| return con | ||
| return sqlite3.connect('output/deepminer.db') | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def connectDB(): | ||
| con = sqlite3.connect('output/deepminer.db', timeout=30) | ||
| return con | ||
| return sqlite3.connect('output/deepminer.db', timeout=30) | ||
|
Comment on lines
-9
to
+8
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def createTables(con): | ||
| cur = con.cursor() | ||
|
|
@@ -66,8 +64,7 @@ def searchDB(term,con): | |
| cur = con.cursor() | ||
| query = "SELECT URL,Directory FROM Deepdata WHERE HTML LIKE \'%" + term + "%\' ORDER BY URL;" | ||
| cur.execute(query) | ||
| results = cur.fetchall() | ||
| return results | ||
| return cur.fetchall() | ||
|
Comment on lines
-69
to
+67
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def createFTStable(con): | ||
| cur = con.cursor() | ||
|
|
@@ -83,5 +80,4 @@ def searchFTS(term,con): | |
| cur = con.cursor() | ||
| query = "SELECT URL,Directory FROM Deepsearch WHERE HTML MATCH \'" + term + "\' ORDER BY rank;" | ||
| cur.execute(query) | ||
| results = cur.fetchall() | ||
| return results | ||
| return cur.fetchall() | ||
|
Comment on lines
-86
to
+83
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines
12-17refactored with the following changes:use-fstring-for-concatenation)use-join)str()from formatted values in f-strings (remove-str-from-fstring)simplify-generator)