タイトルそのままです。UserAgent(UA)を変更する方法を紹介します。UserAgentを確認するために「確認君+」を使います。まずはデフォルトで「確認君+」にアクセスすると以下です。


AddArgumentで解決する
AddArgument関数でUserAgent文字列を指定するのみです。
サンプルプログラム(コピペでOK)
Option Explicit
Sub sample()
Dim dr As New Selenium.WebDriver
dr.AddArgument "user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0"
dr.Start "Chrome"
dr.Get "https://env.b4iine.net/"
Stop
End Sub
サンプルプログラムで「確認君+」にアクセスすると以下の結果が得られます。

