Issue
Before I spend too much time researching this I though I would ask the question here to make sure that it is even possible what I am trying to do.
Context: I am trying to help a friend who is a truck driver. He uses a dispatch website to select his freights. The website lists everything that is available as a list but it does not let him filter by zip code. Basically he has to manually scroll this big list looking for deliveries. If he finds something on his zip code or around it he selects it.
Question: Is it possible to auto-scroll the website, filter by zip code and select an item, if it matches?
There are no available APIs that would allow me to do this programmatically. So I though maybe there is a way to scroll the website using JavaScript and select base on a particular field (zip code).
Is this even possible? Is there a better way to go about this?
Answering the question: Selenium Webdriver can be used for this.
var driver = new ChromeDriver();
driver.Navigate().GoToUrl("https://en.wikipedia.org/wiki/List_of_most_visited_websites");
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
// scroll by element - find element by link text and store in variable "Element"
WebElement Element = (WebElement)driver.FindElement(By.LinkText("United States"));
js.ExecuteScript("arguments[0].scrollIntoView();", Element);
System.Threading.Thread.Sleep(5000);
Console.Read();
Solution
Selenium webdriver would allow a programmer to access the web page and scrape desired content based on a field. However, some sites prohibit scraping data and it depends on the specific site/fields.
Answered By - Kat Cow
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.