This repository has been archived by the owner on Jan 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathNumSpy.py
92 lines (84 loc) · 3.46 KB
/
NumSpy.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
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
from dashtable import html2rst
from requests import get, HTTPError
from argparse import ArgumentParser
api = "link"
def banner():
print("""
__ _ __ __ __ __ _______ _______ __ __
| | | || | | || |_| || || || | | |
| |_| || | | || || _____|| _ || |_| |
| || |_| || || |_____ | |_| || |
| _ || || ||_____ || ___||_ _|
| | | || || ||_|| | _____| || | | |
|_| |__||_______||_| |_||_______||___| |___|
A truecaller Indian Number Search API
Created By: DeBugger (Sameer Bhatt)
T3r@bYt3 (Gurkirat Singh)
V1Ru5 (MohammadYahya)
""")
pass
def search_single(number, store=False, file=None):
print("<--[ Searching Details For {} ]-->".format(number), end="\n\n")
try:
r = get(api.format(number=number))
raw = r.content.decode()
data = "<table>" + raw.split("<table>")[1].split("</table>")[0] + "</table>"
op = html2rst(data)
if store and file:
with open(file, "w") as f:
f.write("Phone Number Details For : {}\n\n".format(number))
f.write(op)
f.close()
print("[!] Search Result is stored in {}".format(file))
else:
print(op)
except HTTPError as e:
print("[x] Check Your Internet Connection")
pass
def multiple_search(store=False, file=None, readfile=False):
global f
if file and store:
f = open(file, "w")
nums = [x for x in open(readfile, "r").read().split("\n") if x is not ""]
for num in nums:
print("\n<--[ Searching Details For {} ]-->".format(num), end="\n\n")
try:
r = get(api.format(number=num))
raw = r.content.decode()
data = "<table>" + raw.split("<table>")[1].split("</table>")[0] + "</table>"
op = html2rst(data)
if store and file:
f.write("Phone Number Details For : {}\n".format(num))
f.write(op)
f.write("\n\n===============================================================\n\n")
pass
else:
print(op)
except HTTPError as e:
print("[x] Check Your Internet Connection")
if file and store:
print("Saved seach result to {}".format(file))
pass
def main():
parser = ArgumentParser(description="A python program to find the details of number from truecaller")
parser.add_argument("--number", help="Target number which you want to search", metavar="")
parser.add_argument("-o", "--output", help="Output file name to store search results", metavar="")
parser.add_argument("-r", help="Accepts a file name for bulk search\nNote: Store numbers line by name in file", metavar="")
args = parser.parse_args()
if args.number is None and args.r is None:
parser.parse_args(["-h"])
num = args.number
file = args.r
ofile = args.output
if file is None and ofile is None:
search_single(num)
elif file is None and ofile is not None:
search_single(num, store=True, file=ofile)
elif file is not None and ofile is None:
multiple_search(readfile=file)
else:
multiple_search(readfile=file, store=True, file=ofile)
pass
if __name__ == '__main__':
banner()
main()