我一直在用硒的webdriver和phantomDriver和CSQuery在.NET一会儿刮黑莓的网站,我至今仍未曾与更新的问题。
//Creating dynamic browser and download the page source code
//based on apipath by using selenium web driver
public IWebDriver driver;
driver = new PhantomJSDriver(phantomDriverPath);
//driver=new ChromeDriver(chromeDriverPath);
driver.Url = "https://appworld.blackberry.com/webstore/search/"+appname+"/lang=en&countrycode=IN";
driver.Navigate();
//Waiting for page loading Thread.Sleep(2000);//2 seconds
if (driver.PageSource != null){
//Assigning downloaded page source code to CSQuery
CQ dom = CQ.CreateDocument(driver.PageSource);
//Waiting for page loading
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));
//find the elements what ever you want based on the id,class name,tag name
string title1 = dom["#topListtopResultsAppTemplateHTML_listItem_0_title"].Text();
}
开始之前编码,请下载硒的webdriver和幻象驱动程序在你的电脑(如C:\Users\rakesh\Documents\Selenium\PhantomJSDriver
),并在您的Visual Studio安装CSQuery。
安装的webdriver:
Install-Package Selenium.WebDriver
安装phantomjs: