PowerAutomateでWebスクレイピング
今回はPowerAutomateでWebから情報をExcelに自動転記する処理を自動化します。
今回は試しにMonotaroの商品情報を収集してみようと思います。
環境
Microsoft Windows 11 Home
Excel デスクトップ アプリ
GoogleChrome
PowerAutomate Desktop 無償版
まず初めにChromeでChrome拡張のアドオンのMicrosoft Power Automateの機能をインストールします。
ChromeウェブストアにアクセスしてPowerAutoMateで検索してChromeに追加をクリックして拡張機能を追加して下さい。

PowerAutoMateを起動し新しいフローを作成します。

フロー名を入力してください、特に名前に制約はないですので分かりやすい名前をつけてください、今回はWebOperationにします。

アクションでWebを検索するとWebに関連するアクションを出るので「新しいChromeを起動する」をドラッグ&ドロップしていきます。

今回はMonotaroのカテゴリのファイリングを初期URLに設定します。


次にアクションでウィンドウでを検索して「Webページからデータを抽出する」をドラッグ&ドロップしていきます。
先ほどの「新しいChromeを起動する」の変数を指定します。

次に取得対象のWebページを開いておき、操作するページを選択すると次のようなウィンドウが表示されます。

その状態で取得したいデータを選択して右クリックすると、要素が取得できるので「要素の値を抽出」で「テキスト:」を選択します。

今回は商品名と価格を設定します。

次に取得した値をExcelに保存します。
最初に保存用のExcelを起動します、「Excelの起動」をドラッグ&ドロップし「次のドキュメント」を選択しドキュメントパスを選択して下さい。

※パスは自身の保存しているパスを選択して下さい。
その後「Excelワークシートに書き込む」をドラッグ&ドロップし、書き込む値の変数を記入して下さい。

全て設定すれば下記の画像のようになります。

その後保存して、▷実行して下さい。
実行後エクセルファイルが起動して下記のように商品名と価格の値がコピーされていると思います。
