Tag: getelementsbyclassname

使用getelement来获得具有多个值的类

我正在使用VBScript和getElementsByClassName从HTML获取数据到Excel。 不幸的是,一个网站已经改变了他们的编码,所以现在我不确定如何获得class级中的数据,因为它现在分成几个部分。 页面源代码如下所示: <span class="mod-tearsheet-recommendation__visual__column"> <i data-recommendation-count="5" style="background-color:#458B00; height:25%"></i> <i data-recommendation-count="2" style="background-color:#74A840; height:10%"></i> <i data-recommendation-count="11" style="background-color:#777777; height:55%"></i> <i data-recommendation-count="2" style="background-color:#DF6060; height:10%"></i> <i data-recommendation-count="0" style="background-color:#CC0000; height:0%"></i> </span> 我只对值5,2,11,2,0感兴趣。 http://markets.ft.com/data/equities/tearsheet/forecasts?s=MMM:NYQ 我使用这样的getElementByClassname : ws.Range(“V2”)。Value = objExplorer.document.getElementsByClassName(“mod-tearheet-recommendation__visual__column”)(1).innerHtml 但这并不能区分课堂上的价值。 有没有办法在课堂上获得每个“我数据推荐计数”值?

VBA Excel在HTMLObject中获取文本

我知道这对你们中的一些人来说非常简单。 但是我一直在深入互联网,我找不到答案。 我需要得到公司内部的名字 tbody tr td a eBay-tradera.com 和 td class="bS aR" 970,80 /td /tr /tbody <tbody id="matrix1_group0"> <tr class="oR" onmouseover="onMouseOver(this, false)" onmouseout="onMouseOut(this, false)" onclick="onClick(this, false)"> <td class="bS">&nbsp;</td> <td> <a href="aProgramInfoApplyRead.action?programId=175&amp;affiliateId=2014848" title="http://www.tradera.com/" target="_blank"> eBay-Tradera.com </a> </td> <td class="aR"> <a href="/pan/aProgramInfoApplyRead.action?programId=175&amp;affiliateId=2014848" title="/pan/aProgramInfoApplyRead.action?programId=175&amp;affiliateId=2014848">175</a></td> <td class="bS aR">0</td><td class="bS aR">0</td><td class="bS aR">187</td> <td class="aR">0,00%</td><td class="bS aR">124</td> <td class="aR">0,00%</td> <td […]

vba,getElementsByClassName,HTMLSource的双引号不见了

我用VBA刮了一些网站的乐趣,我用VBA作为工具。 我使用XMLHTTP和HTMLDocument(因为它比internetExplorer.Application更快)。 Public Sub XMLhtmlDocumentHTMLSourceScraper() Dim XMLHTTPReq As Object Dim htmlDoc As HTMLDocument Dim postURL As String postURL = "http://foodffs.tumblr.com/archive/2015/11" Set XMLHTTPReq = New MSXML2.XMLHTTP With XMLHTTPReq .Open "GET", postURL, False .Send End With Set htmlDoc = New HTMLDocument With htmlDoc .body.innerHTML = XMLHTTPReq.responseText End With i = 0 Set varTemp = htmlDoc.getElementsByClassName("post_glass post_micro_glass") For […]

使用VBA excel多个类名从网站拉取数据

我知道这已被问了很多次,但没有看到一个明确的答案循环通过一个div和findind标签具有相同的类名。 我的第一个问题: 如果我有这样的事情: <div id="carousel"> <div id="images"> <div class="imageElement"> <img src="img/image1.jpg"> </div> <div class="imageElement"> <img src="img/image2.jpg"> </div> <div class="imageElement"> <img src="img/image3.jpg"> </div> </div> </div> 所以我想把所有的img Src与div中的“images”一起放入imageElement类名中,并将它们复制到excel中的某些单元格中。 第二个问题:我已经看到了用VBA拉网站内容的两种方法,一种是使用IE,另一种是使用浏览器的代码。 Private Sub pullData_Click() Dim x As Long, y As Long Dim htm As Object Set htm = CreateObject("htmlFile") With CreateObject("msxml2.xmlhttp") .Open "GET", "http://website.html", False .send htm.body.innerHTML = .responsetext […]