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