2

I need to write standalone application which will "browse" external resource. Is there lib in C# which automatically handles cookies and supports JavaScript (through JS is not required I believe)? The main goal is to keep session alive and submitting forms so I could pass multistep registration process or "browse" web site after login. I reviewed Html Agility Pack but it looks like it doesn't contain functionality I need - form submitting or cookie support.

Thanks, Artem.

  • 1
    Here's a great walkthrough to get HtmlUnit working from C#: http://blog.stevensanderson.com/2010/03/30/using-htmlunit-on-net-for-headless-browser-automation/ – Jerod Venema Oct 21 '10 at 14:22

5 Answers5

3

If you're interested in writing your own version of htmlunit for C#, the IKVM project may be of help. http://www.ikvm.net/

Hasturkun
  • 35,395
  • 6
  • 71
  • 104
Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
1

The HtmlAgilityPack is specifically for parsing HTML. You can use the WebRequest class in the .NET Framework to handle communication and cookies.

See my blog entry on Web scraping in .NET. This won't answer all your questions, but will get you part of the way there.

TrueWill
  • 25,132
  • 10
  • 101
  • 150
1

Look at Data Extracting SDK, which allows to post data via HtmlProcessor class. Also you can add your work item here if it is missed in the library.

sashaeve
  • 9,387
  • 10
  • 48
  • 61
  • Thank you. Not the exact thing but much closer to what I need than WebRequest –  Oct 03 '09 at 17:45
0

http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.aspx Try you WebBrowser class and work with DOM there

Regfor
  • 8,515
  • 1
  • 38
  • 51
0

Selenium, it uses the actual browsers, but is a cross browser platform. Depends on wether or not you can have an actual browser running - it works by injecting javascript via a proxy into the browser. http://seleniumhq.org/support/

Zac
  • 3,235
  • 4
  • 25
  • 30
  • While Selenium does web testing, it is fundamentally different from HTMLUnit. HTMLUnit works by senting responses and receiving responses, parsing html, & abstracting all that away from the user. – fooMonster Oct 11 '11 at 17:14
  • "senting responses and receiving responses, parsing html, & abstracting all that away from the user" - you've just described a web browser, which is what Selenium automates, and what HTMLUnit *is* (though 'headless', having no visible display). From a programming perspective the required coding is approximately the same: filling in text fields and clicking buttons via their respective APIs. – agentnega Feb 02 '12 at 07:08