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


基础教程推荐
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01