-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRRSSSearch.py
More file actions
147 lines (132 loc) · 5.37 KB
/
RRSSSearch.py
File metadata and controls
147 lines (132 loc) · 5.37 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
from bs4 import BeautifulSoup
import request
import urllib.request
import sys
import phonenumbers
from phonenumbers import geocoder
from phonenumbers import carrier
# define ANSI escape sequences for colored output
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
# a function for each site, which creates the request according to the username
def whatsapp(number):
url = "https://api.whatsapp.com/send?phone=" + number + "/"
html_page = urllib.request.urlopen(url)
soup = BeautifulSoup(html_page, "lxml")
gButton = soup.find('div', attrs={"class": "_whatsapp_www__block_action"})
r = gButton is None
if r:
print(bcolors.OKGREEN + url + ": 404: Available" + bcolors.ENDC)
else:
print(bcolors.FAIL + url + ": 200: Already Exists" + bcolors.ENDC)
def bitbucket(username):
url = "https://bitbucket.org/" + username + "/"
request = urllib.request.Request(url)
try:
parse(request,username)
except urllib.error.URLError :
print(bcolors.FAIL + url)
print(bcolors.FAIL + "Fail in the url, Probably this page can't have a usernames whit this characters (/ , _ . -)")
except UnicodeError:
print(bcolors.FAIL + url)
print(bcolors.FAIL + "Fail in the url, Probably this page can't have a usernames whit this characters (/ , _ . -)")
def github(username):
url = "https://github.com/" + username + "/"
request = urllib.request.Request(url)
try:
parse(request,username)
except urllib.error.URLError :
print(bcolors.FAIL + url)
print(bcolors.FAIL + "Fail in the url, Probably this page can't have a usernames whit this characters (/ , _ . -)")
except UnicodeError:
print(bcolors.FAIL + url)
print(bcolors.FAIL + "Fail in the url, Probably this page can't have a usernames whit this characters (/ , _ . -)")
def twitter(username):
url = "https://twitter.com/" + username + "/"
request = urllib.request.Request(url)
try:
parse(request,username)
except urllib.error.URLError :
print(bcolors.FAIL + url)
print(bcolors.FAIL + "Fail in the url, Probably this page can't have a usernames whit this characters (/ , _ . -)")
except UnicodeError:
print(bcolors.FAIL + url)
print(bcolors.FAIL + "Fail in the url, Probably this page can't have a usernames whit this characters (/ , _ . -)")
def instagram(username):
url = "https://instagram.com/" + username + "/"
request = urllib.request.Request(url)
try:
parse(request,username)
except urllib.error.URLError :
print(bcolors.FAIL + url)
print(bcolors.FAIL + "Fail in the url, Probably this page can't have a usernames whit this characters (/ , _ . -)")
except UnicodeError:
print(bcolors.FAIL + url)
print(bcolors.FAIL + "Fail in the url, Probably this page can't have a usernames whit this characters (/ , _ . -)")
def facebook(username):
url = "http://facebook.com/" + username + "/"
request = urllib.request.Request(url)
try:
parse(request,username)
except urllib.error.URLError :
print(bcolors.FAIL + url)
print(bcolors.FAIL + "Fail in the url, Probably this page can't have a usernames whit this characters (/ , _ . -)")
except UnicodeError:
print(bcolors.FAIL + url)
print(bcolors.FAIL + "Fail in the url, Probably this page can't have a usernames whit this characters (/ , _ . -)")
def tumblr(username):
url = "https://" + username + ".tumblr.com"
request = urllib.request.Request(url)
try:
parse(request,username)
except urllib.error.URLError :
print(bcolors.FAIL + url)
print(bcolors.FAIL + "Fail in the url, Probably this page can't have a usernames whit this characters (/ , _ . -)")
except UnicodeError:
print(bcolors.FAIL + url)
print(bcolors.FAIL + "Fail in the url, Probably this page can't have a usernames whit this characters (/ , _ . -)")
def geoCach(number):
chNumber = (phonenumbers.parse(number, 'CH'))
sNum = phonenumbers.parse(number, 'RO')
print(geocoder.description_for_number(chNumber, "en"))
print(carrier.name_for_number(sNum, "en"))
# process the request and capture the response code
def middleware(request, username):
try:
response = urllib.request.urlopen(request)
except urllib.error.HTTPError as e:
if e.code == 404:
return (404, "Available")
else:
return (e.code, e.reason)
else:
if response.getcode() == 200:
return (200, "Already exists")
# used for generating colored responses
def parse(request, username):
response = middleware(request, username)
if response[0] == 200:
# printout(response, RED)
print(bcolors.FAIL + request.get_full_url() + ": 200: Already Exists" + bcolors.ENDC)
elif response[0] == 404:
# printout(response, GREEN)
print(bcolors.OKGREEN + request.get_full_url() + ": 404: Available" + bcolors.ENDC)
# Menu
username = input("Username to check: ")
number = input("Number to check: ")
print("Checking for availability of '" + username + "', please wait...")
facebook(username)
twitter(username)
instagram(username)
github(username)
tumblr(username)
bitbucket(username)
whatsapp(number)
geoCach(number)