File size: 754 Bytes
3f9f23d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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")