seawolf2357 commited on
Commit
cdbedd5
ยท
verified ยท
1 Parent(s): 9eb2a18

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -9,7 +9,7 @@ def fetch_pdf_links_and_titles():
9
  soup = BeautifulSoup(response.text, 'html.parser')
10
 
11
  seen_urls = set()
12
- links_and_titles = []
13
  # ๋ชจ๋“  PDF ๋งํฌ์™€ ์ œ๋ชฉ์„ ์ฐพ์Šต๋‹ˆ๋‹ค.
14
  pdf_links = soup.find_all('a', href=re.compile("^https://ssl.pstatic.net/imgstock/upload/research/company/.*\.pdf$"))
15
  for link in pdf_links:
@@ -17,17 +17,17 @@ def fetch_pdf_links_and_titles():
17
  full_url = link['href']
18
  if full_url not in seen_urls:
19
  seen_urls.add(full_url)
20
- # ์ค‘๋ณต ์ œ๊ฑฐ ํ›„ ๋‹ค์šด๋กœ๋“œ ๊ฐ€๋Šฅํ•œ ๋งํฌ ํ˜•ํƒœ๋กœ ์ €์žฅ
21
- links_and_titles.append([title, f"<a href='{full_url}' download='{full_url.split('/')[-1]}'>{full_url}</a>"])
22
- return links_and_titles
23
 
24
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค
25
  with gr.Blocks() as app:
26
  btn_fetch = gr.Button("PDF ๋งํฌ ๋ฐ ์ •๋ณด ์กฐํšŒ")
27
- output_links = gr.Dataframe(headers=["Title", "PDF ๋งํฌ"], interactive=False)
28
  btn_fetch.click(
29
  fn=fetch_pdf_links_and_titles,
30
- outputs=output_links
31
  )
32
 
33
  app.launch()
 
9
  soup = BeautifulSoup(response.text, 'html.parser')
10
 
11
  seen_urls = set()
12
+ links_html = ""
13
  # ๋ชจ๋“  PDF ๋งํฌ์™€ ์ œ๋ชฉ์„ ์ฐพ์Šต๋‹ˆ๋‹ค.
14
  pdf_links = soup.find_all('a', href=re.compile("^https://ssl.pstatic.net/imgstock/upload/research/company/.*\.pdf$"))
15
  for link in pdf_links:
 
17
  full_url = link['href']
18
  if full_url not in seen_urls:
19
  seen_urls.add(full_url)
20
+ # HTML ๋ฌธ์ž์—ด๋กœ ๋งํฌ ์ถ”๊ฐ€
21
+ links_html += f"<div><a href='{full_url}' download='{full_url.split('/')[-1]}'>{title}</a></div>"
22
+ return links_html
23
 
24
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค
25
  with gr.Blocks() as app:
26
  btn_fetch = gr.Button("PDF ๋งํฌ ๋ฐ ์ •๋ณด ์กฐํšŒ")
27
+ output_html = gr.HTML()
28
  btn_fetch.click(
29
  fn=fetch_pdf_links_and_titles,
30
+ outputs=output_html
31
  )
32
 
33
  app.launch()