AWS Cloud9でSeleniumからHeadless Chromeを使うまで【Python3】
ググってもいいのが出てこなかったから備忘録
Cloud9でPython3を使うまでの設定は省略(リクエストがあれば書きます)
1.seleniumをインストールします
pip install selenium --user
2.chromeをインストールします
curl https://intoli.com/install-google-chrome.sh | bash
3.chromedriverをダウンロードします
curl -SL https://chromedriver.storage.googleapis.com/2.42/chromedriver_linux64.zip > chromedriver.zip
4.ダウンロードしたzipを解凍します
unzip chromedriver.zip
以上だよ
以下サンプルコード
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--headless')
♯解凍したchromedriverが置いてあるパスを指定してね
driver = webdriver.Chrome('/home/ec2-user/environment/chromedriver', chrome_options=options)
driver.get('https://www.google.co.jp/search?q=chrome')
driver.save_screenshot('screenshot.png')
driver.quit()
![screenshot.png]
↑こんなスクショが出来たら完成です
Cloud9もPythonも始めたばっかで
コードはコピぺ&ガバガバなのは許してね(⋈◍>◡<◍)。✧♡
ようこそ、steemitへ
日本のコミニティを応援している @steemit-jpです。@steemit-jpは日本の良い記事を推薦するJapan Daily Curationを実施しています。
また、新しいメンバーへのサポートを推進しています。レピテーション50になるまでタグに jp-newbie を使用していただくと支援のvoteをいたします。
その他イベントなども開催しておりますので、ぜひご参加ください。それでは楽しいsteemit生活をお過ごしください。
日本コミュニティのDiscordチャットで質問もOK!登録しよう!
Congratulations @kakel! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
はじめまして。 @yasu24と申します。よろしくお願いします。
Posted using Partiko iOS
はじめまして、よろしくお願いします。