gpt4 book ai didi

internet-explorer - 导航到网站、全选、复制并粘贴到记事本中

转载 作者:行者123 更新时间:2023-12-04 10:17:12 28 4
gpt4 key购买 nike

我正在尝试创建一个 VB 脚本来导航到网站、全选、复制,然后将复制的数据从剪贴板保存到文本文件,但我被卡住了! :(

这是我到目前为止得到的:

With CreateObject("InternetExplorer.Application")
.Navigate "https://www.microsoft.com"
Do Until .ReadyState = 4: Wscript.Sleep 100: Loop
.Visible = true
With .Document
.execCommand "SelectAll"
.execCommand "Copy"
End With ' Document

最佳答案

可以尝试直接从DOM中获取文本数据

With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate "https://www.microsoft.com"
Do Until .ReadyState = 4
Wscript.Sleep 100
Loop
For Each Tag In .Document.GetElementsByTagName("script")
Tag.OuterHtml = ""
Next
For Each Tag In .Document.GetElementsByTagName("noscript")
Tag.OuterHtml = ""
Next
Content = .Document.GetElementsByTagName("body")(0).InnerText
Do While InStr(Content, vbCrLf & vbCrLf)
Content = Replace(Content, vbCrLf & vbCrLf, vbCrLf)
Loop
ShowInNotepad Content
.Quit
End With

Sub ShowInNotepad(Content)
With CreateObject("Scripting.FileSystemObject")
TempPath = CreateObject("WScript.Shell").ExpandEnvironmentStrings("%TEMP%") & "\" & .GetTempName
With .CreateTextFile(TempPath, True, True)
.WriteLine (Content)
.Close
End With
CreateObject("WScript.Shell").Run "notepad.exe " & TempPath, 1, True
.DeleteFile (TempPath)
End With
End Sub

关于internet-explorer - 导航到网站、全选、复制并粘贴到记事本中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21437573/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com