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
74 lines (61 loc) · 1.61 KB
/
Copy pathapi.py
File metadata and controls
74 lines (61 loc) · 1.61 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
"""
API Module
Provides access to external services using API wrappers
"""
import requests
from .log import debug
from .config import host, port
base_url: str = f'http://{host}:{port}'
def get_node(link: str, depth: int):
"""
Returns the LinkTree for the given link at the specified depth.
"""
endpoint = f'/tree?link={link}&depth={depth}'
url = base_url + endpoint
debug(f'requesting {url}')
resp = requests.get(url)
data = resp.json()
debug(f'retrieved {data}')
return data
def get_ip():
"""
Returns the IP address of the current Tor client the service is using.
"""
endpoint = '/ip'
url = base_url + endpoint
debug(f'requesting {url}')
resp = requests.get(url)
debug(f'retrieved {resp.text}')
return resp.text
def get_emails(link: str):
"""
Returns the mailto links found on the page.
"""
endpoint = f'/emails?link={link}'
url = base_url + endpoint
debug(f'requesting {url}')
resp = requests.get(url)
data = resp.json()
debug(f'retrieved {data}')
return data
def get_phone(link: str):
"""
Returns the tel links found on the page.
"""
endpoint = f'/phone?link={link}'
url = base_url + endpoint
debug(f'requesting {url}')
resp = requests.get(url)
data = resp.json()
debug(f'retrieved {data}')
return data
def get_web_content(link: str):
"""
Returns the HTML content of the page.
"""
endpoint = f'/content?link={link}'
url = base_url + endpoint
debug(f'requesting {url}')
resp = requests.get(url)
debug(f'retrieved {resp.text}')
return resp.text