-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
146 lines (111 loc) · 3.79 KB
/
main.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
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
# Coded By SpiderX
# Modules
from bs4 import BeautifulSoup
import requests
import tag_list
def SHOTGUN():
print("""
,______________________________________
|_________________,----------._ [____] ""-,__ __....-----=====
(_(||||||||||||)___________/ "" |
`----------' SpiderX[ ))"-, |
"" `, _,--....___ |
`/ ''''
""")
# Getting Web URL
SHOTGUN()
print("Web Scraping Tool by Gigahertz Legacy- SpiderX")
print("\n")
print("Enter The url -- ex: https://facebook.com")
url = input("Enter the url : ")
# Getting Source Code
get_req = requests.get(url)
content = get_req.content
tag_list.ALL_TAGS()
while True:
soup = BeautifulSoup(content, 'html.parser')
try:
user_input = int(input("Enter your Choice :"))
print("\n")
if user_input == 1:
source = soup.prettify()
print(source)
elif user_input == 111:
with open('html.txt', 'w') as HtmlFile:
HtmlFile.write(str(content))
HtmlFile.close()
elif user_input == 999:
print("Just Enter the tag name, ex: cite")
custom_tag_input = input("Enter the tag :")
cus_tag = soup.find_all(f'{custom_tag_input}')
print(cus_tag)
elif user_input == 2:
a_tag = soup.find_all('a')
print(a_tag)
elif user_input == 4:
img_tag = soup.find_all('img')
print(img_tag)
elif user_input == 3:
anchors = soup.find_all('a')
all_links = set()
for links in anchors:
if links.get('href') != "#":
links = f"{url}" + links.get('href')
all_links.add(links)
print(links)
elif user_input == 5:
p_tag = soup.find_all('p')
print(p_tag)
elif user_input == 6:
bq_tag = soup.find_all('blockquote')
print(bq_tag)
elif user_input == 7:
comment_tag = soup.find_all('!--')
print(comment_tag)
elif user_input == 8:
table_tag = soup.find_all('table')
print(table_tag)
elif user_input == 9:
ul_tag = soup.find_all('ul')
print(ul_tag)
elif user_input == 10:
div_tag = soup.find_all('div')
print(div_tag)
elif user_input == 11:
span_tag = soup.find_all('span')
print(span_tag)
elif user_input == 12:
iframe_tag = soup.find_all('iframe')
print(iframe_tag)
elif user_input == 13:
script_tag = soup.find_all('script')
print(script_tag)
elif user_input == 14:
title_tag = soup.find_all('title')
print(title_tag)
elif user_input == 15:
meta_tag = soup.find_all('meta')
print(meta_tag)
elif user_input == 16:
code_tag = soup.find_all('code')
print(code_tag)
elif user_input == 17:
section_tag = soup.find_all('section')
print(section_tag)
elif user_input == 18:
body_tag = soup.find_all('body')
print(body_tag)
elif user_input == 19:
canvas_tag = soup.find_all('canvas')
print(canvas_tag)
elif user_input == 20:
svg_tag = soup.find_all('svg')
print(svg_tag)
elif user_input == 404:
tag_list.ALL_TAGS()
elif user_input == 909:
exit()
else:
print("Type between the given integers---")
except Exception as e:
print(e)