WebBrowsing in C# - Libraries, Tools etc. - Anything like Mechanize in Perl? [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
开发者_开发问答 Improve this questionLooking for something similar to Mechanize for .NET...
If you don't know what Mechanize is.. http://search.cpan.org/dist/WWW-Mechanize/
I will maintain a list of suggestions here. Anything for browsing/posting/screen scraping (Other than WebRequest and WebBrowser Control).
Parsing
- HTMLAgilityPack - http://www.codeplex.com/htmlagilitypack
Web App Testing
WatiN - Web Application Testing Framework (.NET) - http://watin.sourceforge.net/
Selenium - http://seleniumhq.org/
Art of Test Design Canvas - Costs Money
Tools
- Firebug for Firefox
- Internet Explorer Developer Toolbar for IE
- Chrome has one too
Note
WatiN is close to what I am looking for, except it opens up a browser, which is annoying and awesome at the same time. Depends on what you are doing.
You can use the WebBrowser
control, which can be automated to an extent.
I've been using WatiN to great effect. It's an easy way to 1) automate user input w/ IE and 2) navigate the DOM.
You need to use the HTML Agility Pack, which can parse tag soup from real websites into a DOM structure.
You can also use Selenium. It's for unit testing web sites. It has a java application that drives the browser and a C# interface that you can write your code in. It also has the downside of showing the browser, but it's pretty full featured in terms of control, waiting on responses and getting the results.
Design Canvas is the best tool out there for this type of thing. Works with IE, Firefox, Safari, or an in-memory browser. It allows you to record and then playback any kind of web interaction.
You want HttpWebRequest for automating web requests and HtmlAgilityPack for processing the resulting HTML.
I have reverse engineered Python-Mechanize, and recreated it in C#, called Mechanize.NET.
https://github.com/WilliamABradley/Mechanize.NET
This should hopefully cover all use cases of Mechanize, if not, or you discover a bug, create an issue.
It uses .NET Standard, so it should be usable across .NET, such as with F#, VB, etc.
It utilises HtmlAgilityPack internally, and you can even collect the HtmlDocument for each loaded page.
精彩评论