<tr ><th scope="row" class="left " data-append-csv="abdelal01" data-stat="player" ><a href="/players/a/abdelal01.html">Alaa Abdelnaby</a></th><td class="right " data-stat="year_min" >1991</td><td class="right " data-stat="year_max" >1995</td><td class="center " data-stat="pos" >F-C</td><td class="right " data-stat="height" csk="82.0" >6-10</td><td class="right " data-stat="weight" >240</td><td class="left " data-stat="birth_date" csk="19680624" ><a href="/friv/birthdays.cgi?month=6&day=24">June 24, 1968</a></td><td class="left " data-stat="college_name" ><a href="/friv/colleges.cgi?college=duke">Duke University</a></td></tr>
<tr ><th scope="row" class="left " data-append-csv="abdulza01" data-stat="player" ><a href="/players/a/abdulza01.html">Zaid Abdul-Aziz</a></th><td class="right " data-stat="year_min" >1969</td><td class="right " data-stat="year_max" >1978</td><td class="center " data-stat="pos" >C-F</td><td class="right " data-stat="height" csk="81.0" >6-9</td><td class="right " data-stat="weight" >235</td><td class="left " data-stat="birth_date" csk="19460407" ><a href="/friv/birthdays.cgi?month=4&day=7">April 7, 1946</a></td><td class="left " data-stat="college_name" ><a href="/friv/colleges.cgi?college=iowast">Iowa State University</a></td></tr>
<tr ><th scope="row" class="left " data-append-csv="abdulka01" data-stat="player" ><a href="/players/a/abdulka01.html">Kareem Abdul-Jabbar</a>*</th><td class="right " data-stat="year_min" >1970</td><td class="right " data-stat="year_max" >1989</td><td class="center " data-stat="pos" >C</td><td class="right " data-stat="height" csk="86.0" >7-2</td><td class="right " data-stat="weight" >225</td><td class="left " data-stat="birth_date" csk="19470416" ><a href="/friv/birthdays.cgi?month=4&day=16">April 16, 1947</a></td><td class="left " data-stat="college_name" ><a href="/friv/colleges.cgi?college=ucla">University of California, Los Angeles</a></td></tr>
<tr ><th scope="row" class="left " data-append-csv="abdulma02" data-stat="player" ><a href="/players/a/abdulma02.html">Mahmoud Abdul-Rauf</a></th><td class="right " data-stat="year_min" >1991</td><td class="right " data-stat="year_max" >2001</td><td class="center " data-stat="pos" >G</td><td class="right " data-stat="height" csk="73.0" >6-1</td><td class="right " data-stat="weight" >162</td><td class="left " data-stat="birth_date" csk="19690309" ><a href="/friv/birthdays.cgi?month=3&day=9">March 9, 1969</a></td><td class="left " data-stat="college_name" ><a href="/friv/colleges.cgi?college=lsu">Louisiana State University</a></td></tr>
<tr ><th scope="row" class="left " data-append-csv="abdulta01" data-stat="player" ><a href="/players/a/abdulta01.html">Tariq Abdul-Wahad</a></th><td class="right " data-stat="year_min" >1998</td><td class="right " data-stat="year_max" >2003</td><td class="center " data-stat="pos" >F</td><td class="right " data-stat="height" csk="78.0" >6-6</td><td class="right " data-stat="weight" >223</td><td class="left " data-stat="birth_date" csk="19741103" ><a href="/friv/birthdays.cgi?month=11&day=3">November 3, 1974</a></td><td class="left " data-stat="college_name" ><a href="/friv/colleges.cgi?college=sanjosest">San Jose State University</a></td></tr>
嗨
我需要点击每个玩家的链接
我的代码需要一些帮助
For Each ele In objIE.document.getElementById("players").getElementsByTagName("a")
THX
答案 0 :(得分:0)
if ($sta =="1"){
print("<tr bgcolor=#2E0854>\n");
}
if ($sta =="2"){
print("<tr bgcolor=#000000>\n");
}
print("<td>$sta</td>\n");
print("<td>$name</td>\n");
print("<td>$info</td>\n");
print("<td>$day</td>\n");
print("</tr>\n");
}
答案 1 :(得分:0)
我认为锚对我不起作用或者我没有完成:(
结果必须是 http://www.basketball-reference.com/players/a/abdelal01.html http://www.basketball-reference.com/players/a/abdulza01.html 等
我的完整代码
Sub basketballreference()
Dim objIE As InternetExplorer
Dim elealphabet As Object
Dim eleplayertable As Object
Dim r As Integer
Dim c As Integer
Dim letter As String
Dim MyString As String
Dim MyLetter As String
Set objIE = New InternetExplorer
objIE.navigate "http://www.basketball-reference.com/players/"
objIE.Visible = True
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
For Each elealphabet In objIE.document.getElementsByClassName("alphabet inline")
MyString = Replace(elealphabet.textContent, "X", "")
'Close all opened ie browser
Dim objWMI As Object, objProcess As Object, objProcesses As Object
Set objWMI = GetObject("winmgmts://.")
Set objProcesses = objWMI.ExecQuery( _
"SELECT * FROM Win32_Process WHERE Name = 'iexplore.exe'")
Dim j As Integer
j = objProcesses.Count
For Each objProcess In objProcesses
If j > 1 Then Shell "taskkill /f /PID " & CStr(objProcess.ProcessID), vbHide
j = j - 1
Next
Set objProcesses = Nothing
Set objWMI = Nothing
Set objIE = Nothing
For i = 2 To Len(MyString)
MyLetter = LCase(Mid(MyString, i, 1))
Set objIE = New InternetExplorer
objIE.navigate "http://www.basketball-reference.com/players/" & MyLetter & "/"
objIE.Visible = True
Application.Wait Now + TimeValue("00:00:02")
While objIE.Busy Or objIE.readyState <> READYSTATE_COMPLETE: DoEvents: Wend
For Each eleplayertable In objIE.document.getElementById("players").getElementsByTagName("a")
'must go to players page
Next
Next i
Next
End Sub
答案 2 :(得分:0)
2年回答:)
如果您仍然遇到问题,请尝试此操作
Set elemCollection = IE.document.getElementsByTagName("a")(2)
'Debug.Print elemCollection.Length
'Debug.Print elemCollection.body.innerHTML
For Each tagx In tags
If tagx.href = "your href" Then
tagx.Click
End If
Next
希望这有帮助
最好的问候
Sameur