protected void Page_Load(object sender, EventArgs e) { //var webClient = new WebClient(); //var form = new BasicHtmlForm(webClient); //form.Load(new Uri("http://www.weather.gov/"), new KeyValuePair<string, string>("name", "getForecast")); //form.InputControls.Single(c => c.Name == "inputstring").Value = "fairbanks, ak"; //using (var response = form.Submit()) //{ // if (response.ResponseType == WebResponseType.Html) // { // var scraper = new TestScraper(((HtmlWebResponse)response).Html); // var conditions = scraper.GetConditions(); // var temperature = scraper.GetTemperature(); // System.Diagnostics.Debug.WriteLine(conditions); // Weather.InnerText = temperature; // var scraper2 = new TestScraper2(((HtmlWebResponse)response).Html); // var craigslist = scraper2.GetList(); // } //} var webClient1 = new WebClient(); var form1 = new BasicHtmlForm(webClient1); form1.Load(new Uri("https://www.trulia.com/rent/"), new KeyValuePair <string, string>("data-reactid", "29")); form1.InputControls.Single(c => c.Name == "location-autocomplete").Value = "Frisco, TX"; using (var response = form1.Submit()) { if (response.ResponseType == WebResponseType.Html) { var scraper2 = new TestScraper2(((HtmlWebResponse)response).Html); // var craigslist = scraper2.GetList(); // Weather.InnerText = craigslist; } } IWebDriver driver = new PhantomJSDriver(); driver.Navigate().GoToUrl("https://twitter.com/Twitter"); var backpack = driver.Title; var back = driver.FindElement(By.XPath("//*[@class='u-linkComplex-target']")); var backpack2 = driver.FindElement(By.XPath("//*[contains(@class,'twitter-timeline-link')]/span[2]")); }
public void ScrapeTest() { var webClient = new WebClient(); var form = new BasicHtmlForm(webClient); form.Load(new Uri("http://www.weather.gov/"), new KeyValuePair <string, string>("name", "getForecast")); form.InputControls.Single(c => c.Name == "inputstring").Value = "fairbanks, ak"; using (var response = form.Submit()) { if (response.ResponseType == WebResponseType.Html) { var scraper = new TestScraper((( HtmlWebResponse )response).Html); var conditions = scraper.GetConditions(); var temperature = scraper.GetTemperature(); } } }