Spaces:
Sleeping
Sleeping
| from bs4 import BeautifulSoup | |
| import requests | |
| import re | |
| url = "https://www.anlp.jp/proceedings/annual_meeting/2025/" | |
| 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()) | |
| # 後処理 | |
| pattern = r'^([A-Z]\d+-\d+)' | |
| match = re.match(pattern, pair[0]) | |
| if pair[0] and pair[1] and match: | |
| extracted_pairs.append((match.group(1), pair[1])) | |
| with open("anlp2025.tsv", "w") as f: | |
| for pair in extracted_pairs: | |
| f.write(f"{pair[0]}\t{pair[1]}\n") |