30 lines
859 B
Python
30 lines
859 B
Python
|
from bs4 import BeautifulSoup
|
||
|
from urllib.parse import quote, unquote
|
||
|
import requests
|
||
|
|
||
|
def get_files(url: str) -> []:
|
||
|
if (url in ["/../", "../"]):
|
||
|
return ([])
|
||
|
response = requests.get(url)
|
||
|
if (response.status_code != 200):
|
||
|
print("connection:", response.reason)
|
||
|
sys.exit(1)
|
||
|
soup = BeautifulSoup(response.text, 'html.parser')
|
||
|
files = []
|
||
|
for element in soup.findAll("a"):
|
||
|
files.append(unquote(element["href"]))
|
||
|
return (files)
|
||
|
|
||
|
def get_uri(url: str) -> []:
|
||
|
if (url in ["/../", "../"]):
|
||
|
return ([])
|
||
|
try:
|
||
|
response = requests.get(url)
|
||
|
if (response.status_code != 200):
|
||
|
print("connection:", response.reason)
|
||
|
sys.exit(1)
|
||
|
soup = BeautifulSoup(response.text, 'html.parser')
|
||
|
return(soup.find("h1").text[9:])
|
||
|
except:
|
||
|
return ("")
|