基本1(id要素のtextcontent取得)
async def main():
browser = await launch()
page = await browser.newPage() #(a)
await page.goto('https://sisterroom.stchan130.com/')
hosoku = await page.querySelector('#hosoku')
print(hosoku_ihtml)
await browser.close() # ブラウザーを終了する。
if __name__ == '__main__':
asyncio.run(main())
基本2(ブラウザにchromeを使う&ブラウザを表示する)
#(a)を下記に変更する
browser = await launch({"headless":False,
"executablePath":'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'})
参考
Pyppeteerを使ってみる
Puppeteer (Chrome の自動操作ライブラリ) を Python に移植してpyppeteerという名前で公開しました
Pythonでスクレイピング - Seleniumなんてもう古い!?・・・Pyppeteerの使い方
書籍『Pythonクローリング&スクレイピング[増補改訂版] -データ収集・解析のための実践開発ガイド』