-1

我想在 Firefox 当前页面 html 中替换字符串(“123”与“111”)。

解释:

我正在打开 Firefox,然后我正在导航到:

www.site.com/print.php?string=123

我正在等到文件完全加载

页面html:

<html>
<body>
123
</body>
</html>

我将字符串“123”替换为“111”。

代码应如下所示:

        openff("http://www.site.com/print.php?string=123") 'open url
again:
        For Each p As Process In Process.GetProcessesByName("firefox") 'wait until page is fully loaded
            If p.MainWindowTitle = "123 page title" Then
                Exit For
            Else
                Application.DoEvents()
                GoTo again
            End If
        Next
        replaceInFFcurrentDocHtml("123", "111") 'Replace the string!!!

该功能replaceInFFcurrentDocHtml()实际上并不存在。

有一个函数可以replace在firefox当前页面html中字符串吗?

或者get当前 html 来自的函数firefox

(我试图通过 spy++ 使用句柄和窗口获取 html,但这种方式不起作用)

4

2 回答 2

0

您可以编写和 Firefox 扩展来修改页面内容,许多扩展都是这样做的。

或者我相信 Greasemonkey 脚本也可以做同样的事情,https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/

于 2012-12-24T15:24:21.130 回答
0

这本身并不完全是“入侵Firefox”,但它可能会起作用。

使用WebClient并将站点的内容下载为字符串,使用您可能真正需要的任何内容调用该字符串的替换,并将结果写入临时 html 文件。最后,要么专门调用 firefox 来打开所述 html 文件,要么要求操作系统解决哪个应用程序应该使用Process.Start打开它。

我相信 Firefox(出于安全原因,任何浏览器都不应该)允许对 DOM 进行外部修改。这是唯一有效的方法,无需对 Firefox 的代码进行一些复杂的修改。

另外,一个不错的提示:不要使用 GoTo,这是个坏主意

于 2012-12-24T08:18:41.573 回答