0

I am working on a project in which one functionality is that this page obtains data from other page (not web service) and then displays it on a grid and use hightcharts for charting. The problem is that this data I want to read is in anotherpage. I know that I can read html from other pages... but to get this information on the page, I need to fill 2 input text for a filter and press a submit button.. then it displays a table and this is the table where I need to extract the information.

Is there a way to do this automatically on c#?

jcvegan
  • 3,111
  • 9
  • 43
  • 66

1 Answers1

3

There are plenty of ways to do this; the most common revolve around AJAX. You can initiate a callback from the client via Javascript to a method on the server, which can update controls in an UpdatePanel, for example.

You can also make client side calls to server side Page Methods. Effectively, this is a static method on your webform that you can call from the client via javascript/jquery and AJAX.

EDIT.

It turns out that you want to scrape another site. The easiest way for you to do this is have a server side page method on your website that does this - it requests the page from the client site, extracts the info you want, and then returns that to your client. Your client can of course call this as a page method.

See https://web.archive.org/web/20210513000146/http://www.4guysfromrolla.com/webtech/070601-1.shtml for a tutorial, and I do suggest using the HTML Agility Pack as that article mentions.

Further EDIT

You want to further manipulate the page on the remote site; if you can't or don't want to speak to the developers of that site to work out a way of doing it programmatically, then you'll have to cheat. Get Firebug and Tamper Data. Use Firebug and Tamper Data to see how clicking the button on the remote site makes a request and posts it to the server - you want to emulate doing the same. If you know what data is being posted then you can, from your server, make exactly the same post.

You often have this kind of problem when trying to scrape AJAX websites.

Community
  • 1
  • 1
dash
  • 89,546
  • 4
  • 51
  • 71
  • But I need to this this to other page, not in my solution... this page is a newspaper page, I need to obtain only certain data from its web page... – jcvegan Feb 24 '12 at 14:16
  • Ah, okay! What you need to do is "scrape" the other application. You can have a server side method on your site that does this, and the client can call this server side method which "scrapes" the other site, extracts the data you want and returns it to your client. See http://www.4guysfromrolla.com/webtech/070601-1.shtml for a guide. – dash Feb 24 '12 at 14:22
  • Yes but I want to manipulate that, submit a button and do some things more – jcvegan Feb 24 '12 at 14:29
  • You can - you just need to put your functionality for manipulating the code in server side page methods that you can call from your browser via UpdatePanels or jQuery :-) So when you click the button, it makes an async postback to your web server code behind, which then makes a call to the newspaper, gets some data back, filters it, and then sends the data back to the client as part of the async request. You can have as many of those kind of methods as you want. – dash Feb 24 '12 at 14:35
  • Remember, you don't even have to click the button - you can fire off some javascript when the page finishes loading to do this automatically. – dash Feb 24 '12 at 14:41
  • but the button isn't on my page... is on the page which I want to obtain the data – jcvegan Feb 24 '12 at 14:49