I'm trying to navigate to page x of several pages of search results in Startpage.com. I can successfully parse the object to an IHTMLElement.getElementByID("2"); and I use it's Click() event to fire the javascript behind it. Still the document stays on the first page of search results.
private void GetNextPage(int i_page)
{
HTMLDocument hdoc_Doc = (HTMLDocument)wb1.Document; // wb1 is at page one of search results
IHTMLElement element_Page = hdoc_Doc.getElementByID(i_page.ToString());
if (null != element_Page)
{
element_Page.click();
}
// Now check to see which titles are showing
IHTMLElement element_OneCheck = hdoc.getElementByID("title_1"); // Page one search results
IHTMLElement element_TwoCheck = hdoc.getElementByID("title_11"); // this is on page 2 search results if it gets there...
if (null != element_OneCheck)
Console.WriteLine("Page One Still...");
if (null != element_TwoCheck)
Console.WriteLine("Page Two found...");
}
The result is: "Page One Still..." I have even tried direct action on the document:
hdoc_Doc.getElementByID("2").click;
Once again this worked but did not advance the document to the next page of search results. I have also parsed this out with the HTMLAgilityPack, but that is for parsing not processing a javascript link, which is why I went this route.
Any help would be much appreciated! I am on .NET 4.0 using VS 2010 (yes, I know it is old, but is Ultimate versus the free versions I have for the newer VS - so I stick with 2010 for full environment.)
Aucun commentaire:
Enregistrer un commentaire