Spaces:
Sleeping
Sleeping
File size: 926 Bytes
738953f 43a0009 0750144 43a0009 0750144 a027460 9efc58b 0750144 43a0009 0750144 a844404 0750144 43a0009 |
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 |
import gradio as gr
import requests
from bs4 import BeautifulSoup
import re
def fetch_pdf_links():
url = "https://finance.naver.com/research/company_list.naver"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
# 모든 PDF 링크를 찾습니다.
pdf_links = soup.find_all('a', href=re.compile("\.pdf$"))
links = []
for link in pdf_links:
full_url = "https://finance.naver.com" + link['href']
# 다운로드 가능한 링크 형태로 저장
links.append([f"<a href='{full_url}' download='{full_url.split('/')[-1]}'>{full_url.split('/')[-1]}</a>"])
return links
# Gradio 인터페이스
with gr.Blocks() as app:
btn_fetch = gr.Button("PDF 링크 조회")
output_links = gr.Dataframe(headers=["PDF 링크"], interactive=False)
btn_fetch.click(
fn=fetch_pdf_links,
outputs=output_links
)
app.launch()
|