Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm developing a basic app that will perform a Google search based on a text field value and then open a web page based on a given Google result. I have this working, but only on the first result. I can't get access to the remaining results.

In firebug, I see this code for the first three listings

HTML
<h3 class="r">
<a class="l"  önmousedown="return rwt(this,'','','','2','AFQjCNGm_Xkvwld9e7TYNqWga_fksOOKlA','','0CDUQFjAB','','',event)" href="http://www.ht-llc.com/">
HealthTech Solutions
Group
</a>
</h3>

<h3 class="r">
<a class="l"  önmousedown="return rwt(this,'','','','2','AFQjCNGm_Xkvwld9e7TYNqWga_fksOOKlA','','0CDUQFjAB','','',event)" href="http://www.ht-llc.com/">
HealthTech Solutions
Group
</a>
</h3>

<h3 class="r">
<a class="l"  önmousedown="return rwt(this,'','','','4','AFQjCNF9v26pz2xQuVtIciioX883AVShsA','','0CEgQFjAD','','',event)" href="http://4hts.com/">
</h3>



Because they each have a class of "l", I have the code set up to look for the href value of the links with class of "l".

C#
string resultStats = browser.Element(Find.ByClass("l")).GetAttributeValue("href").ToString();
                           
                            //Display URL in text box
                            txtResults.Text = "Opening URL: " + resultStats;


How can I modify this to pull back all the results, or at least let me select a specific one other than the first?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900