File size: 910 Bytes
b18a9b9
 
 
0e31147
 
b18a9b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0e31147
 
 
 
 
 
 
b18a9b9
 
 
 
 
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
31
32
33
34
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")