loading html, clicking radiobutton and saving the new page to the hdd

Topics: Developer Forum
Jul 22, 2010 at 11:52 AM
I m new with html agility pack. I have a problem as follows: I have a console app. I need to have the page with a url i do that : HtmlWeb hw = new HtmlWeb(); //string url = @"http://www.asdfa.com"; HtmlDocument doc = hw.Load(url); then in that page must click a radiobutton (directing a new page) The problem is that i cant make the program click a radiobutton in that page, and take the directed page by the radiobutton. at last i need to save the page in my hdd smwhere. Can anybody help?
Jul 22, 2010 at 12:34 PM
HTML Agility Pack is not a browser engine, it knows nothing of javascript, nor CSS. It simply parses the html into a data form. It cannot and will never do any sort of interactivity like that. To do what you need to do you will probably need to create a windows program that hosts the Web Browser control which brings the IE engine into your program where you can inject some JS to do the click.
Jul 23, 2010 at 10:43 AM

ok well, I have HtmlDocument doc = hw.Load(url),  how do i add <script type="text/javascript" src="jscript.js"></script> in <head> tags? could this solve my problem? Thank you very much

Aug 12, 2010 at 9:28 AM

You need parse <form> tag and compose new url. You can read for example: http://www.w3schools.com/html/html_forms.asp

If you composing GET request, you will get something like this url: http://www.google.lt/#hl=lt&source=hp&q=html+for+dummies&aq=f&aqi=g2&aql=&oq=&gs_rfai=&fp=b27f0e9f0b50bb44

But if you must POST on the page, then you can do like that: http://www.netomatix.com/httppostdata.aspx