//static void Main(string[] args) //{ // FileStream fs = new FileStream("gsm.txt", FileMode.Open); // StreamReader sr = new StreamReader(fs); // string str = ""; // while ((str = sr.ReadLine()) != null) // { // StartCrawl(str); // } // //StartCrawl("http://www.gsmarena.com/huawei-phones-58.php"); // //DisplayDetails(); // /*This is the code with which Abot Crawl Links/HyperLinks from some Specific Website*/ // /*Abot Crawler does Depth Crawling that is it jumps from one hyper link to another*/ // /*I have Crawled links of iphone6 and stored them in a file*/ // /*This code is commented because once Abot start Crawling it won't stop. It may take several hours*/ // /*Can be uncommented to verify*/ //} static void crawler_ProcessPageCrawlStartingGSM(object sender, PageCrawlStartingArgs e) { PageToCrawl pageToCrawl = e.PageToCrawl; string url = pageToCrawl.ToString(); if ((url.Contains("samsung") || url.Contains("apple") || url.Contains("microsoft") || url.Contains("nokia") || url.Contains("sony") || url.Contains("lg") || url.Contains("htc") || url.Contains("motorola") || url.Contains("huawei") || url.Contains("blackberry") || url.Contains("lenovo") || url.Contains("oppo") || url.Contains("lava")) && (url.Contains("_") && (!(url.Contains("pictures"))) && (!(url.Contains("reviews"))) && (!(url.Contains("review"))))) { FileStream fs = new FileStream("../../../Users/Hp Mobile Workstatio/Documents/Visual Studio 2013/Projects/Working/FYPAdam/AdamDal/bin/Debug/UrlGSM.txt", FileMode.Append); StreamWriter sw = new StreamWriter(fs); sw.WriteLine(url); sw.Close(); fs.Close(); } Console.WriteLine("About to crawl link {0} which was found on page {1}", pageToCrawl.Uri.AbsoluteUri, pageToCrawl.ParentUri.AbsoluteUri); }
//static void Main(string[] args) //{ // FileStream fs = new FileStream("ebuyer.txt", FileMode.Open); // StreamReader sr = new StreamReader(fs); // string str = ""; // while ((str = sr.ReadLine()) != null) // { // StartCrawl(str); // } // //DisplayDetails(); //} public static void crawler_ProcessPageCrawlStarting(object sender, PageCrawlStartingArgs e) { try { PageToCrawl pageToCrawl = e.PageToCrawl; string url = pageToCrawl.ToString(); if ((url.Contains("apple") || url.Contains("hp") || url.Contains("lenovo") || url.Contains("asus") || url.Contains("dell") || url.Contains("acer")) && url.Contains("-") && ((url.Contains("laptop")) || (url.Contains("chromebook")) || (url.Contains("ultrabook")) || (url.Contains("transformer")) || (url.Contains("tablet")) || (url.Contains("macbook")) || (url.Contains("laptops")))) { FileStream fs = new FileStream("../../../Users/Hp Mobile Workstatio/Documents/Visual Studio 2013/Projects/FYP DB Fix UP/FYPAdam/AdamDal/bin/Debug/UrlEbuyer.txt", FileMode.Append); // FileStream fs = new FileStream("UrlEbuyer.txt", FileMode.Append); //FileStream fs = new FileStream(@"~\AdamDal\bin\Debug\url.txt", FileMode.Append); StreamWriter sw = new StreamWriter(fs); sw.WriteLine(url); sw.Close(); fs.Close(); } Console.WriteLine("About to crawl link {0} which was found on page {1}", pageToCrawl.Uri.AbsoluteUri, pageToCrawl.ParentUri.AbsoluteUri); }catch (Exception) { } }