本文整理汇总了C#中Service.Scrape方法的典型用法代码示例。如果您正苦于以下问题:C# Service.Scrape方法的具体用法?C# Service.Scrape怎么用?C# Service.Scrape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Service
的用法示例。
在下文中一共展示了Service.Scrape方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanPersistComparison
//[Test]
public void CanPersistComparison()
{
//Arrange
var qbService = new Service();
var myScrapeA = qbService.Scrape("www.google.com", false);
var myScrapeB = qbService.Scrape("www.google.com", false);
//Act
var comparer = new Comparer();
var myComparison = comparer.Compare(myScrapeA, myScrapeB);
//Assert
Assert.IsTrue(!String.IsNullOrEmpty(myComparison.Id.ToString()), "Comparison Id is Null or Empty: {0}", myComparison.Id.ToString());
}
示例2: CanPersistScrape
//[Test]
public void CanPersistScrape()
{
//Arrange
var qbService = new Service();
//Act
var myScrape = qbService.Scrape("www.google.com");
//Assert
Assert.IsTrue(!String.IsNullOrEmpty(myScrape.Id.ToString()));
}
示例3: CanCompareScrapes
//[Test]
public void CanCompareScrapes()
{
//Arrange
var tmpScraper = new Service();
var tmpScrapeA = tmpScraper.Scrape(new Request("www.ancestry.com"));
var tmpMongoIdA = new MongoDB.Bson.ObjectId(DateTime.Now, 0, 0, 0);
tmpScrapeA.Id = tmpMongoIdA;
var tmpScrapeB = tmpScraper.Scrape(new Request("www.ancestrystage.com"));
var tmpMongoIdB = new MongoDB.Bson.ObjectId(DateTime.Now, 0, 0, 0);
tmpScrapeB.Id = tmpMongoIdB;
//Act
var qbService = new Comparer();
var retvalComparison = qbService.Compare(tmpScrapeA, tmpScrapeB);
//Assert
Assert.AreEqual(retvalComparison.Scrapes[0].IdString, tmpScrapeA.IdString, "Compare failed: Invalid ScrapeIDs Expected: {0}", tmpMongoIdA);
Assert.AreEqual(retvalComparison.Scrapes[1].IdString, tmpScrapeB.IdString, "Compare failed: Invalid ScrapeIDs Expected: {0}", tmpMongoIdB);
}
示例4: VerifyScrapeWithPhantomJS
//[Test, Category("Integration")]
public void VerifyScrapeWithPhantomJS()
{
//Arrange
var qbService = new Service();
var request = new Request
{
Url = "http://www.google.com/",
Browser = "phantomjs"
};
//Act & Assert
Assert.DoesNotThrow(() =>
{
var result = qbService.Scrape(request);
Assert.IsTrue(result.Url == request.Url);
Assert.IsTrue(result.Browser == request.Browser);
});
}
示例5: Scrape
/// HELPER METHODS ///
private Scrape Scrape(Request request)
{
var scraper = new Service();
var scrape = scraper.Scrape(request);
return scrape;
}
示例6: TestSaveScrapeToFileSystem
//[Test]
public void TestSaveScrapeToFileSystem()
{
var url = "http://www.google.com?timestamp=" + GetTimestamp();
var scraper = new Service();
var request = new Request(url, _browser, _browserVersion, _resolution);
var scrape = scraper.Scrape(request);
var persister = PersisterFactory.CreateScrapePersisterInstance(@"C:\OutputDirectory\TestSaveScrapeToFileSystem");
// cleanup
if (Directory.Exists(persister.OutputDir)) Directory.Delete(persister.OutputDir, true);
// save
persister.Save(scrape);
// verify
Assert.IsTrue(Directory.Exists(persister.OutputDir));
var files = Directory.GetFiles(persister.OutputDir);
Assert.IsTrue(files.Any(f => f.Contains("Html.html")));
Assert.IsTrue(files.Any(f => f.Contains("scrape.json")));
Assert.IsTrue(files.Any(f => f.Contains("Screenshot.png")));
}
示例7: Scrape
public dynamic Scrape(string url, bool persist)
{
var qBSvc = new Service();
return qBSvc.Scrape(url, persist);
}