Spaces:
Sleeping
Sleeping
File size: 663 Bytes
738953f 4012bf8 43a0009 4012bf8 7e27e95 4012bf8 0750144 4012bf8 43a0009 4012bf8 |
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 |
import gradio as gr
import re
import requests
from bs4 import BeautifulSoup
def extract_pdf_links(url):
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
pdf_links = []
for link in soup.find_all('a', href=True):
if re.search(r'\.pdf', link['href']):
pdf_links.append(link['href'])
return pdf_links[:10]
def generate_html(pdf_links):
html = ""
for link in pdf_links:
html += f'<a href="{link}" target="_blank">{link}</a><br/>'
return html
iface = gr.Interface(extract_pdf_links,
inputs="text",
outputs="text")
iface.launch() |