问题描述
我有一个 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!