尝试硒+;Excel VBA从Chrome浏览器中的站点中刮取代码
我需要一些关于使用Excel(2013)VBE中的Selenium Basic ChromeDriver(v 75.0.3770.140)在Chrome(v 75.0.3770.142)中从网站上抓取文本的指导 以下是HTML:尝试硒+;Excel VBA从Chrome浏览器中的站点中刮取代码,excel,vba,selenium,xpath,css-selectors,Excel,Vba,Selenium,Xpath,Css Selectors,我需要一些关于使用Excel(2013)VBE中的Selenium Basic ChromeDriver(v 75.0.3770.140)在Chrome(v 75.0.3770.142)中从网站上抓取文本的指导 以下是HTML: <div ng-if="!ShippingDetails.isShippingCreatedOutsideSH" ng-bind="ShippingDetails.code" class="">3333333</div> 试试这个 Debug.
<div ng-if="!ShippingDetails.isShippingCreatedOutsideSH" ng-bind="ShippingDetails.code" class="">3333333</div>
试试这个
Debug.Print .FindElementByXPath("//div[@ng-bind='ShippingDetails.code']").Text
要打印文本3333333,您可以使用以下任一选项:
- 使用
:CSS\u选择器
- 使用
:.Text
Debug.Print .FindElementByCss("div[ng-if$='isShippingCreatedOutsideSH'][ng-bind^='ShippingDetails']").Text
Debug.Print .FindElementByXPath("//div[contains(@ng-if, 'isShippingCreatedOutsideSH') and starts-with(@ng-bind, 'ShippingDetails')]").Text
- 使用
:.Attribute(“innerHTML”)
- 使用
- 使用
:XPATH
- 使用
:.Text
Debug.Print .FindElementByCss("div[ng-if$='isShippingCreatedOutsideSH'][ng-bind^='ShippingDetails']").Text
Debug.Print .FindElementByXPath("//div[contains(@ng-if, 'isShippingCreatedOutsideSH') and starts-with(@ng-bind, 'ShippingDetails')]").Text
- 使用
:.Attribute(“innerHTML”)
- 使用
Debug.Print .FindElementByXPath("//div[contains(@ng-if, 'isShippingCreatedOutsideSH') and starts-with(@ng-bind, 'ShippingDetails')]").Attribute("innerHTML")