Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel VBA:在脚本后面删除HTML数据_Vba_Excel_Web Scraping - Fatal编程技术网

Excel VBA:在脚本后面删除HTML数据

Excel VBA:在脚本后面删除HTML数据,vba,excel,web-scraping,Vba,Excel,Web Scraping,我有这个HTML,我正在尝试在“Compra:”和“Venta:”之后刮取data-v-88f004c6后面的值 坎比奥·德拉尔·霍伊·佩鲁酒店 康帕: 文塔: 我是用 CSS选择器 #__layout span:nth-child(2) +*") 'compra #__layout span:nth-child(3) +*") 'venta 以下是完整选择器的合同版本: #__layout > div > main > section.banner > di

我有这个HTML,我正在尝试在“Compra:”和“Venta:”之后刮取
data-v-88f004c6
后面的值


坎比奥·德拉尔·霍伊·佩鲁酒店
康帕:

文塔:

我是用

CSS选择器

#__layout span:nth-child(2) +*") 'compra
#__layout span:nth-child(3) +*") 'venta 
以下是完整选择器的合同版本:

#__layout > div > main > section.banner > div.central-section > div.col.paddingTop2 > section > div > span:nth-child(2) > strong
#__layout > div > main > section.banner > div.central-section > div.col.paddingTop2 > section > div > span:nth-child(3) > strong

CSS查询示例:

源页面值


代码:


注:


安装Selenium basic并打开excel后,您需要通过VBE>工具>引用>Selenium类型库添加引用

是否尝试获取包含您在文章中提到的值的表?你试过使用IE吗?IE是从Excel中抓取数据的另一种方法?我还没试过。但奇怪的是,这个函数不起作用,这是我第一次遇到问题。这是你第一次遇到这样的麻烦,因为你从来没有刮过任何动态生成的项目。但是,无论是
winhttp
xmlhttp
、还是
serverxmlhttp
,它们都无法处理javascript繁重的项目。所以,在这种情况下,你最好的选择是选择任何浏览器模拟器。嗨,你试过这个了吗?我努力帮你回答。是的,但不是在我的工作终端上。我不能在那台计算机上安装selenium。
Option Explicit
Public Sub GetInfoSel()
    Dim d As WebDriver, keys As New keys
    Set d = New ChromeDriver
    Const URL = "https://kambista.com/"

    With d
        .Start "Chrome"
        .Get URL
          Debug.Print .FindElementByCss("#__layout span:nth-child(2) +*").Text 'compra
          Debug.Print .FindElementByCss("#__layout span:nth-child(3) +*").Text  'venta
        .Quit
    End With
End Sub