Running Selenium on Azure Web App(在 Azure Web 应用程序上运行 Selenium)
问题描述
我有一个 Azure Web 应用程序,当我在控制器上调用 Action 时,我想用它来屏幕抓取网站,就像这样.
I have an Azure Web App that I want to use to screen scrape a website when I call an Action on a controller, like so.
var driver = new PhantomJSDriver();
driver.Url = "http://url.com";
driver.Navigate();
var source = driver.PageSource;
var pathElement = driver.FindElementByXPath("//table[@class='someclassname']");
string innerHtml = "";
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
if (js != null)
{
innerHtml = (string)js.ExecuteScript("return arguments[0].innerHTML;", pathElement);
}
return innerHtml;
这在本地运行良好,但是当我上传到我的 Azure Web 应用程序时,我收到此错误
This works fine locally, however when I upload to my Azure Web App, I get this error
无法在 http://localhost:51169/
我认为这与防火墙有关,因为我需要在应用程序第一次运行时在我的防火墙设置中批准 PhantomJS.我的问题是如何让它在 Azure 中部署?是否有可能,或者我是否需要将其配置为一些单元测试并从 Visual Studio 中运行?
I assume this has to do with firewalls since I need to approve PhantomJS in my firewall settings the first time the app runs. My question is how do I get this to work deployed in Azure? Is it even possible, or do I need to configure this as some Unit Test and run it from within Visual Studio?
推荐答案
PhantomJS 目前无法在运行 Azure Web Apps 的沙箱中运行.请参阅 wiki 了解已知目前无法正常工作,以及有关沙盒的许多其他信息.
PhantomJS does not work today in the sandbox that Azure Web Apps run under. See the wiki for a list of things that are known to not work currently, as well as lots of other information about the sandbox.
这篇关于在 Azure Web 应用程序上运行 Selenium的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Azure Web 应用程序上运行 Selenium
基础教程推荐
- Moq It.Is<>不匹配 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- WPF 模态进度窗口 2022-01-01
