选项和服务
选项用于添加“User-Agent”等功能。
C#中的示例:
var options = new PhantomJSOptions();
options.AddAdditionalCapability("phantomjs.page.settings.userAgent",
"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0");
using (var driver = new PhantomJSDriver(options))
{
//code
}
服务用于修改 PhantomJS 实例的行为,例如隐藏命令提示符或禁用加载图像。
C#中的示例:
var service = PhantomJSDriverService.CreateDefaultService();
service.HideCommandPromptWindow = true;
service.LoadImages = false;
using (var driver = new PhantomJSDriver(service))
{
//code
}