简体   繁体   English

是否可以通过 WinForm/WPF C# App 与 web 浏览器进行交互?

[英]Is it possible to interact with web browser from WinForm/WPF C# App?

I would like to know if it's technically possible to develop a WinForm or WPF C# application that can interact with any web browser tab.我想知道在技术上是否可以开发可以与任何 web 浏览器选项卡交互的 WinForm 或 WPF C# 应用程序。

Let's imagine I have a Chrome web page with a web form.假设我有一个带有 web 表单的 Chrome web 页面。 I would like to run a WinForm app and be able to point and select a web form field to get the data in it.我想运行一个 WinForm 应用程序并能够指向 select 和 web 表单字段以获取其中的数据。 Exactly like the F12 feature of a browser when you can use the Select feature and use your mouse to select a DOM element.就像浏览器的 F12 功能一样,您可以使用 Select 功能并使用鼠标 select DOM 元素。 As shown on attached screenshot.如随附的屏幕截图所示。

在此处输入图像描述

F12 is a feature within the web browser, but how can I reproduce the same behaviour with an external custom WinForm/WPF application? F12 是 web 浏览器中的一项功能,但是如何使用外部自定义 WinForm/WPF 应用程序重现相同的行为?

Is it even possible?甚至可能吗?

I don't think there is a way to achieve what you want to do.我认为没有办法实现您想要做的事情。
If there was, anyone could write a program to read all of the data you input into your browser, that would be a security nightmare.如果有的话,任何人都可以编写一个程序来读取您输入到浏览器中的所有数据,那将是一场安全噩梦。

yes, you can do it using Selenium.是的,您可以使用 Selenium 来完成。

Check this out: Selenium .看看这个: Selenium

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM