0
0

More than 3 years have passed since last update.

pyppeteerを使ってみた【着手したとこ】

Last updated at Posted at 2021-03-01

基本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クローリング&スクレイピング[増補改訂版] -データ収集・解析のための実践開発ガイド』

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0