File size: 793 Bytes
7b89807
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import asyncio
from playwright.async_api import async_playwright
async def fetch_train_info():
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page()
        
        # �y�[�W�ɃA�N�Z�X���AJavaScript�̎��s��҂�
        await page.goto("https://traininfo.jreast.co.jp/train_info/kanto.aspx")
        
        # �K�v�ɉ����Ďw�莞�ԑҋ@����i��: 5�b�ҋ@�j
        await page.wait_for_timeout(5000)
        
        # �^�s���̃e�L�X�g���擾
        content = await page.content()  # HTML�S�̂��擾
        train_info = await page.inner_text("body")  # �K�v�ȃZ���N�^���w�肵�Ď擾
        
        print(train_info)
        
        await browser.close()
# ���s
asyncio.run(fetch_train_info())
exit()