Programmatically Clicking on a Web Page's Button in Windows Forms Application

3.4k views Asked by At

I am working on a project which is Analysis of Papers from Google Scholar. What I do is basically, parsing the HTML, storing related fields into database etc. However, I am stuck at a point, while I am taking the Titles of the publications, I realized, I am able to get first twenty elements. But, there are sixty papers in related account:

http://scholar.google.com/citations?user=B7vSqZsAAAAJ

So, I think as a solution, I need to click to the 'show more' button programmatically, so I can have all the Title's, Publication Venue etc.

What do you think? How can I perform that kind of action?

Edit: I checked the 'show more' button, while there is nothing to show as a next page, its html code still remains same. As a solution I can use loop for n times. However, I am looking for more robust solution. Thank you for your time!

2

There are 2 answers

2
nonexistent myth On

If its this website specifically, there is a simple workaround. Change the query string to what records you want.

http://scholar.google.com/citations?user=B7vSqZsAAAAJ&cstart=0&pagesize=2000

0
Baaleos On

If it is clicking on a button within a WebBrowser control on a Windows Form Application, then 'Yes' you can do it. There are ways of getting more control over identification by using XPath.

(You might need to use Javascript to use XPath for object interactions - since you haven't asked for that, I will assume you don't need it)

webBrowser.Navigate("http://www.google.com");

//   Or

HtmlElement textElement = webBrowser.Document.All.GetElementsByName("q")[0];
textElement.SetAttribute("value", "your text to search");
HtmlElement btnElement = webBrowser.Document.All.GetElementsByName("btnG")[0];
btnElement.InvokeMember("click");

Or even typing into text boxes with

webBrowser1.Document.GetElementById("gs_tti0").InnerText = "hello world";