-
Notifications
You must be signed in to change notification settings - Fork 1
/
domain_github.py
executable file
·41 lines (32 loc) · 1.04 KB
/
domain_github.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
#!/usr/bin/env python
import sys
import requests
from bs4 import BeautifulSoup
import json
from termcolor import colored
import time
class style:
BOLD = '\033[1m'
END = '\033[0m'
def github_search(query, code):
print colored(style.BOLD + '\n---> Searching Github for domain results\n' + style.END, 'blue')
time.sleep(0.3)
endpoint_git = "https://github.com/search?q=\"" + query + "\"&type=" + code
req = requests.get(endpoint_git)
soup = BeautifulSoup(req.content, 'html.parser')
mydivs = soup.findAll("span", { "class" : "counter" })
if mydivs and len(mydivs) >= 1:
return "%s Results found in github Codes. \nExplore results manually: %s" % (str(mydivs[0]).split(">")[1].split("<")[0], endpoint_git)
else:
return None
def main():
domain = sys.argv[1]
#make Search github code for the given domain.
git_results = github_search(domain, 'Code')
if git_results is not None:
print git_results
else:
print colored("Sad! Nothing found on github", 'red')
print "\n-----------------------------\n"
if __name__ == "__main__":
main()