1

ASP.NET 4 & C# and

I would like to know which CODE, Classes could be useful for creating a WEB APPLICATION that could:

01 - Connect to an HTML file on the web.
02 - Parse its content (text content).
03 - Find out specific content in a page (for example looking for specific keywords).

Also how to implement:

04 - How to submit information programmatically in HTML page (feeling forms).

I am interested in understanding Classes and general practice and CODE for accomplish this task.

If you have any idea please let me know. Thanks guys once again for your support! :-)

4

3 回答 3

1

我不确定您是否希望您提到的所有事情都执行“服务器端”,但假设是这种情况:

01 - 连接到网络上的 HTML 文件。

查看WebClient课程和HttpWebRequest课程以获得更高级的场景。

02 - 解析其内容(文本内容)。03 - 查找页面中的特定内容(例如查找特定关键字)。

您可能想查看Html Agility Pack,或者如果 Bobince 没有注意到,请查看正则表达式

04 - 如何在 HTML 页面中以编程方式提交信息(感觉形式)。

通常,这将需要发送一个HTTP POST请求,这也可以通过HttpWebRequest该类来完成。

于 2010-10-22T05:26:08.467 回答
1

要解析网页,请查看HTML Agility pack
对于表单传递,您要么需要使用 Firebug 或 Internet Explorer 开发人员工具等工具,要么使用 Wireshark 等嗅探器来查看通过网络发送的内容。
在您的情况下,我还会考虑考虑将其拆分为单独的组件,以便您可以轻松地测试流程的各个部分。

于 2010-10-22T05:38:29.547 回答
0

Use a HttpWebRequest to invoke a request to a page on the web.

You can then parse the HTML response.

To programmatically submit a form, i think you'll need to do it client-side (JavaScript):

document.forms[0].submit();
于 2010-10-22T05:21:01.373 回答