与网页在C#交互 [英] Interacting with web pages in C#

查看:195
本文介绍了与网页在C#交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有是已使用ColdFusion创建了一个网站(不知道这是否事项或没有)。我需要与本网站互动。我需要做的主要事情是导航到不同的页面,然后点击按钮。

There is a website that was created using ColdFusion (not sure if this matters or not). I need to interact with this web site. The main things I need to do are navigate to different pages and click buttons.

我想出了如何做到这两个想法。第一种方法是使用WebBrowser控件。有了这个,我当然可以浏览网页,然后点击按钮(据<一个href=\"http://social.msdn.microsoft.com/Forums/eu/csharplanguage/thread/20474a99-3e11-44ec-815c-614a8d3f4b43\"相对=nofollow>这)。

I have come up with two ideas on how to do this. The first is to use the WebBrowser control. With this, I could certainly navigate pages, and click buttons (According to This).

的另一种方法是直接的HTML交互。不知道究竟是如何做到这一点,但我假设我可以点击按钮或使用HTML请求与页面交互。

The other way is to interact with the html directly. Not sure exactly how to do this, but I am assuming I could click buttons or use HTML requests to interact with the page.

有没有人有一个建议,对哪种方式更好?有没有更好的办法,我没有想到的?

Does anyone have a recommendation on which way is better? Is there a better way that I haven't thought of?

推荐答案

我会使用的Html AgilityPack 解析HTML,然后做职位和与 HttpWebRequest的适当的GET

I'd use Html AgilityPack to parse the html and then do POSTs and GETs appropriately with HttpWebRequest.

虽然有可能使用WebBrowser控件来模拟点击和导航你会得到更多的控制与HTML AgilityPack和HttpWebRequest的关于什么被发送

While it may be possible to use the WebBrowser control to simulate clicks and navigation you get more control with Html AgilityPack and HttpWebRequest regarding what gets sent

这篇关于与网页在C#交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆