-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
60 lines (45 loc) · 1.22 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
import requests
from bs4 import BeautifulSoup as bs4
import keyboard
from time import sleep
import os
import random
def scrape():
os.system('cls')
url = str(input("Website (e.g.: https://google.com):\n"))
response = requests.get(url)
statCode = response.status_code
randNum = random.randint(-10000, 100000000)
text_file = open(f"output{randNum}.txt", "w+")
if statCode == 200:
soup = bs4(response.content, 'html.parser')
links = soup.find_all('a')
for link in links:
print(link['href'])
text_file.write(link['href'] + '\n')
text_file.close()
menu()
else:
print(f'Failed to retrieve the webpage. Status code: {statCode}')
menu()
def information():
os.system('cls')
print('soon..')
sleep(1)
menu()
def menu():
os.system('cls')
print("[1] Scrape")
print("[2] Information")
print("[Q] Quit")
isPressed = False
while not isPressed:
if keyboard.is_pressed("1"):
isPressed = True
scrape()
if keyboard.is_pressed("2"):
isPressed = True
information()
if keyboard.is_pressed("q"):
quit()
menu()