Spaces:
Sleeping
Sleeping
from bs4 import BeautifulSoup | |
import requests | |
url = "https://www.anlp.jp/proceedings/annual_meeting/2024/" | |
response = requests.get(url) | |
response.encoding = response.apparent_encoding | |
html_content = response.text | |
soup = BeautifulSoup(html_content, 'html.parser') | |
extracted_pairs = [] | |
for table in soup.find_all('table'): | |
for tr in table.find_all('tr'): | |
pid_span = tr.find('span', id=True) | |
title_span = tr.find('span', class_='title') | |
if pid_span and title_span: | |
pair = (pid_span.get_text(), title_span.get_text()) | |
if pair[0] and pair[1]: | |
extracted_pairs.append(pair) | |
with open("anlp2024.tsv", "w") as f: | |
for pair in extracted_pairs: | |
f.write(f"{pair[0]}\t{pair[1]}\n") |