我有一个关于如何从此网页抓取数据的问题:
似乎是在iframe中保存,屏幕上出现了一堆javascripting。
当我尝试收集在iframe下保存的span或div或tr标签中的元素时,我似乎无法收集其中的数据。
我所针对的是innertext,它位于class =“pane-legend-item-value pane-legend-line main”的元素中。
显然,innertext将根据光标在特定时间在屏幕上的位置而改变。所以我试图做的是设置一个IE已经加载页面并将光标放在正确的位置,在图形的末尾(为了给我最后一个数据点),然后你可以将光标移出屏幕,然后我写了一些简单的代码来抓取IE窗口,然后尝试了GetElements,就在这时我无法获取任何数据。
这是我的代码到目前为止,它非常粗糙,因为我一直在尝试编辑,因为我阅读了更多选项,但没有任何胜利:( ...任何想法或帮助将非常感激!(屏幕截图是也在底部)
Sub InvestingCom()
Dim IE As InternetExplorer
Dim htmldoc As MSHTML.IHTMLDocument 'Document object
Dim eleColth As MSHTML.IHTMLElementCollection 'Element collection for th tags
Dim eleColtr As MSHTML.IHTMLElementCollection 'Element collection for tr tags
Dim eleColtd As MSHTML.IHTMLElementCollection 'Element collection for td tags
Dim eleRow As MSHTML.IHTMLElement 'Row elements
Dim eleCol As MSHTML.IHTMLElement 'Column elements
Dim elehr As MSHTML.IHTMLElement 'Header Element
Dim iframeDoc As MSHTML.HTMLDocument
Dim frame As HTMLIFrame
Dim ieURL As String 'URL
'Take Control of Open IE
marker = 0
Set objShell = CreateObject("Shell.Application")
IE_count = objShell.Windows.Count
For x = 0 To (IE_count - 1)
On Error Resume Next
my_url = objShell.Windows(x).document.Location
my_title = objShell.Windows(x).document.Title
If my_title Like "*" & "*" Then 'compare to find if the desired web page is already open
Set IE = objShell.Windows(x)
marker = 1
Exit For
Else
End If
Next
'Extract data
Set htmldoc = IE.document 'Document webpage
' I have tried span, tr, td etc tags and various other options
' I have never actually tried collecting an HTMLFrame but googled it however was unsuccessful
End Sub
答案 0 :(得分:1)
我很难从该页面处理两个嵌套的 peer.on('stream', function (stream) {
console.log(stream);
let video = document.querySelector('video')
video.src = window.URL.createObjectURL(stream)
video.play()
})
来收集所需的内容。但无论如何,我终于修复了它。运行以下代码并获取您请求的内容:
iframes