【发布时间】:2015-01-31 19:47:47
【问题描述】:
我正在尝试使用 Selenium 和 PhantomJS 打开一个网站并获取一些数据,但是打开一个网站需要很长时间(大约 30 秒)。每次我打开其他链接时,我都必须等待 30 多秒。我的代码有什么问题?
static void Main(string[] args)
{
IWebDriver browser = new PhantomJSDriver();
var URL = "http://www.cbssports.com/nba/playerrankings ";
browser.Navigate().GoToUrl(URL);
//Position
var title = browser.FindElements(By.CssSelector(".tableTitle"));
Console.WriteLine(title.First().Text);
Console.Read();
}
我尝试做的事情:
1.Set PhantomJS proxy type to none
2.Disable internet option: automatically detect settings
3.Disable IPv6 protocol
PhantomJS release notes 声称,Microsoft Windows 上的网络性能存在一些已知问题。根据发行说明,解决方案是将代理类型设置为无,但这不起作用。
【问题讨论】:
-
您使用的是哪个 selenium 和 phantomjs 版本?谢谢。
-
有一个技巧可以让 phantomjs 不加载所有资产(你不需要 css、图像等)我不记得它了,但如果你用谷歌搜索它,你会找到它.
-
我使用 PhantomJS 1.9.8 和 Selenium 2.44.0
标签: c# performance selenium phantomjs screen-scraping