如何使用vba获取可见文本? [英] How to get the visible text in ie with vba?

查看:207
本文介绍了如何使用vba获取可见文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用excel从网页中删除一些文字。该页面有很多js与决策树,所以当我使用ie.document.body.innertext,我会看到那些if语句。我不想处理那些。我想要他们输出到屏幕上的结果。外部文本不起作用,因为它似乎给出与innertext相同的结果。 Innerhtml&任何关于如何获取屏幕上可见文本的想法?

解决方案

我建议使用Selenium Webdriver,它扩展了基于浏览器的自动化功能。



HERE 是一个很好的概述。



HERE 是下载/文档。 p>

这是一个使用示例:

  Sub GetWebPageText(url $ )
'需要参考SELENIUM WEBDRIVER类型库
Dim selenium作为新的SeleniumWrapper.WebDriver

selenium.StartInternetExplorer,url

硒。打开url

Debug.Print selenium.getBodyText



End Sub


I'm trying to scrape some text from a webpage using excel. The page has a lot of js with decision trees, so when I use ie.document.body.innertext, I will see those if statements. I do not want to deal with those. I want the result that they output onto the screen. outertext doesn't work either because it appears to give the same result as innertext. Innerhtml & outerhtml also show the decision trees.

Any ideas on how to get the visible text that's painted on the screen?

解决方案

I would suggest using the Selenium Webdriver, which extends the ability to do browser-based automation.

HERE is a good overview.

HERE is the download/documentation.

Here is an example of its use:

Sub GetWebPageText(url$)
' REQUIRES REFERENCE TO THE SELENIUM WEBDRIVER TYPE LIBRARY
Dim selenium As New SeleniumWrapper.WebDriver

selenium.Start "InternetExplorer", url

selenium.Open url

Debug.Print selenium.getBodyText



End Sub

这篇关于如何使用vba获取可见文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆