I have been using PhantomJS and Selenium WebDriver to extract the page source from a specific website by implementing the following code snippet:
var driverService = PhantomJSDriverService.CreateDefaultService();
//The issue arises at this point
var driver = new PhantomJSDriver(driverService);
driver.Navigate().GoToUrl(url);
htmlCode = driver.PageSource;
driver.Quit();
While everything runs smoothly on my local machine, I encounter an error when trying to execute the same code in either an Azure Web Job or Azure Website:
Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:50388
A similar error message pops up when using Selenium with Firefox as an Azure Web Job or Azure Website. Although I have enabled "Web Sockets" in the Azure Web App configuration dashboard, the error persists.
The objective is to retrieve the fully rendered (javascript and ajax) page source of a website within an Azure Web Job.