如何以编程方式解析 HTML 文件并提交信息

发布于 2024-09-28 17:07:15 字数 446 浏览 4 评论 0原文

ASP.NET 4 和C# 和

我想知道哪些代码、类可用于创建一个 WEB 应用程序,该应用程序可以:

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).

另外如何实现:

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

我有兴趣了解类和一般实践以及完成此任务的代码。

如果您有任何想法请告诉我。再次感谢各位的支持! :-)

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! :-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

£冰雨忧蓝° 2024-10-05 17:07:15

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

01 - 连接到 HTML 文件
网络。

查看 WebClient类,以及 HttpWebRequest< /code>类用于更高级的场景。

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

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

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

通常,这需要发送 HTTP POST 请求,这也可以通过HttpWebRequest 类。

I'm not sure if you want all of the things that you mention to execute 'server-side', but assuming that this is the case:

01 - Connect to an HTML file on the
web.

Check out the WebClient class, and the HttpWebRequest class for more advanced scenarios.

02 - Parse its content (text content).
03 - Find out specific content in a
page (for example looking for specific
keywords).

You might want to look at the Html Agility Pack, or if Bobince doesn't notice, regular expressions.

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

Typically, this will require sending a HTTP POST request, which too can be accomplished with the HttpWebRequest class.

╰つ倒转 2024-10-05 17:07:15

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

For parsing the web page, have a look at the HTML Agility pack.
For form passing, you either need to use tools like Firebug or the Internet Explorer developer tools or use a sniffer like Wireshark to see what is sent via the network.
I would also consider in your case to consider to split it into seperate components so that you can easily test parts of the process.

情何以堪。 2024-10-05 17:07:15

使用 HttpWebRequest 调用对页面的请求网络。

然后您可以解析 HTML 响应。

要以编程方式提交表单,我认为您需要在客户端(JavaScript)执行此操作:

document.forms[0].submit();

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();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文