forked from DedSecInside/TorBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.py
More file actions
68 lines (57 loc) · 1.85 KB
/
Copy pathapi.py
File metadata and controls
68 lines (57 loc) · 1.85 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
"""
API Module
Provides access to external services using API wrappers
"""
import requests
class GoTor:
"""
An API wrapper for the goTor service
"""
@staticmethod
def get_node(link, depth, address='localhost', port='8081'):
"""
Returns the LinkTree for the given link at the specified depth.
Args:
link (str): link to be used as a root node.
depth (int): depth of the tree
address (str): network address
port (str): network port
"""
url = f'http://{address}:{port}/tree?link={link}&depth={depth}'
resp = requests.get(url)
return resp.json()
@staticmethod
def get_ip(address='localhost', port='8081'):
"""
Returns the IP address of the current Tor client the service is using.
Args:
address (str): network address
port (str): network port
"""
url = f'http://{address}:{port}/ip'
resp = requests.get(url)
return resp.text
@staticmethod
def get_emails(link, address='localhost', port='8081'):
"""
Returns the mailto links found on the page.
Args:
link (str): the page to pull the emails from.
address (str): network address
port (str): network port
"""
url = f'http://{address}:{port}/emails?link={link}'
resp = requests.get(url)
return resp.json()
@staticmethod
def get_phone(link, address='localhost', port='8081'):
"""
Returns the tel links found on the page.
Args:
link (str): the page to pull the phones from.
address (str): network address
port (str): network port
"""
url = f'http://{address}:{port}/phone?link={link}'
resp = requests.get(url)
return resp.json()