我在使用VBA从网站上获取某些数据时遇到了麻烦。 我正在尝试使用人员名单的名字和姓氏,并使用它来从Scopus网站获取特定数据。我感兴趣的数据是第三列的值(“ h-index”)。这是一个URL示例:shorturl.at/fACDW
我要使用的代码如下所述。似乎存在类型不匹配的情况,可能是在检索Class或使用innerText时?尽管很大,但该网址仍然有效。
非常感谢。
Sub TEST()
Dim url As String, i As Long, j As Long, lastRow As Long
Dim html As HTMLDocument
Dim IE As InternetExplorer
Dim elements As IHTMLElementCollection
lastRow = Range("G" & Rows.Count).End(xlUp).Row
'For i = 6 To lastRow
For i = 6 To 15
url = "https://www.scopus.com/results/authorNamesList.uri?sort=count-f&src=al&affilName=ufrj&sid=fbebd210a59f098d494b9658b1103ea7&sot=al&sdt=al&sl=58&s=AUTHLASTNAME%28" & Cells(i, 8) & "%29+AND+AUTHFIRST%28" & Cells(i, 7) & "%29+AND+AFFIL%28ufrj%29&st1=" & Cells(i, 8) & "&st2=" & Cells(i, 7) & "&orcidId=&selectionPageSearch=anl&reselectAuthor=false&activeFlag=true&showDocument=false&resultsPerPage=20&offset=1&jtp=false¤tPage=1&previousSelectionCount=0&tooManySelections=false&previousResultCount=0&authSubject=LFSC&authSubject=HLSC&authSubject=PHSC&authSubject=SOSC&exactAuthorSearch=false&showFullList=false&authorPreferredName=&origin=searchauthorfreelookup&affiliationId=&txGid=3b0875501c88e6ff695240765bc43872"
'Cells(i, 9) = url
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = False
IE.navigate url
While IE.Busy
DoEvents
Wend
While IE.readyState < 4
DoEvents
Wend
Set html = IE.document
Set elements = html.getElementsByClassName("dataCol4 alignRight")
Cells(i, 10) = elements(0).innerText
Next
IE.Quit
Set IE = Nothing
结束子