我正在尝试从网站导入名称和结果列表。该网站需要登录,因此我附上了源代码
<div class="row reports">
<div class="twelve columns end">
<h2 class="green section-title">Student completion</h2>
<div class="sub-menu">
<ul class="inline-list completetion-filter">
<li>View:</li>
<li><a href="#" data-filter="all" class="selected">All</a></li>
<li><a href="#" data-filter="completed" class="unselected">Completed</a></li>
<li><a href="#" data-filter="not-completed" class="unselected">Not completed</a></li>
<li><a href="#" data-filter="marked" class="unselected">Marked</a></li>
</ul>
</div>
<div class="scroll-list-wrapper scrollable">
<ol class="filter-list">
<li class="not-completed " >
<span class="number purple"></span>
<span class="name">
StudentA </span>
<span class="status">
Awaiting submission </span>
</li>
<li class="complete marked" >
<span class="number purple"></span>
<span class="name">
StudentB </span>
<span class="status">
62.5% </span>
<a href="http://members.gcsepod.com/teachers/reports/view_assignment_answers/1995" class="pink">View answers</a>
</li>
<li class="not-completed " >
<span class="number purple"></span>
<span class="name">
StudentC </span>
<span class="status">
Awaiting submission </span>
</li>
<li class="complete marked" >
<span class="number purple"></span>
<span class="name">
StudentD </span>
<span class="status">
100% </span>
我已经尝试过使用outerHTML和类似的东西,但由于某种原因,它永远不会包含在字符串中。 HTML真的不是我的强项,如果你能给我一些帮助我会非常感激。
由于
我的VBA按要求:
Sub getData()
Const Hyper As String =“http://members.gcsepod.com/teachers/assignments”
Set ie = CreateObject("InternetExplorer.application")
ie.Visible = True
ie.Navigate ("http://members.gcsepod.com/podauth/login")
Do
If ie.ReadyState = 4 Then
'ie.Visible = False
Exit Do
Else
DoEvents
End If
Loop
ie.Visible = True
ie.document.Forms(0).all("username").Value = "****"
ie.document.Forms(0).all("password").Value = "****"
ie.document.Forms(0).submit
Do
If ie.ReadyState = 4 Then
'ie.Visible = False
Exit Do
Else
DoEvents
End If
Loop
ie.Navigate ("http://members.gcsepod.com/teachers/assignments")
ie.Visible = True
Do
If ie.ReadyState = 4 Then
'ie.Visible = False
Exit Do
Else
DoEvents
End If
Loop
Const MASK$ = "data-id="
Dim txt As String, i As Long
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", "http://members.gcsepod.com/teachers/assignments", False
.Send
txt = .ResponseText
End With
Do
i = InStr(i + 1, txt, MASK)
If i = 0 Then Exit Do
'Debug.Print Val(Mid$(txt, i + Len(MASK), 15))
Dim idNum(0 To 10) As String
idNum(0) = Mid(txt, i + 8, 6)
idCount = 0
Do While i > 0
idCount = idCount + 1
txt = Right(txt, Len(txt) - (i + 8))
i = InStr(txt, "data-id=")
'ReDim Preserve idNum(0 To idCount) As String
idNum(Count) = Mid(peopleData, pos + 8, 4)
Loop
Loop
我也尝试了以下内容:
txt = ie.document.all.tags(“ol”)。Item(0).outerHTML
答案 0 :(得分:0)
您是否有权访问该域的相关数据库?如果您使用Access + SQL Server(或MySQL)解决方案,那么可以节省大量时间。