blakearino
Technical User
I would like to scrape a table on a webpage using VBA from excel. I am able to login and open the page but am unable to locate the table as is is an "inception" scenario. The table is generated in javascript from a javascript. Using IE.Application.Document.all I have not been able to locate the table. This is the simplified page:
Using a For loop I can get the elements but none of the tags or names are helpful
I suspect that the javascript may not be an element available to IE.
Any assistance in locating the table would be appreciated.
T.I.A
Blake
Code:
<tr height="100%">
<td height="100%" width="100%" style="border-style:solid;border-color:black;border-width:1px">
<iframe frameborder="0" width="100%" height="100%" src="parents/gradebook/assignmentList.jsp?studentid=140430"></iframe>
</td>
</tr>
[b]parents/gradebook/assignmentList JScript generates this[/b]
<html>
<head>
<link href="../../styles/genesis.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
[b]******* crap to generate calendar stuffs[/b]
</script
<script type="text/javascript">
[b]************** more crap for things I am not interested in[/b]
</script>
</head>
<body class="fieldsarea">
<table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0">
[b]****************** more and moar[/b]
<tr height="100%"><td height="100%" width="100%"><iframe src="assignmentInnerList.jsp" width="100%" height="100%" frameborder="0" style="border:1px solid #000000"></iframe></td></tr>
</table>
<script type="text/javascript">document.getElementById('fldDate').focus();</script>
</body>
</html>
[b]
AssignmentInnerList JScript generates this[/b]
<html>
<head>
<link href="../../styles/genesis.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
function viewDocument(name, type, courseid, stripCode)
{
document.frmAssignments.action = '../../parents?module=gradebook&studentid=7743&action=viewDocument&courseid=' + courseid + '&stripCode=' + stripCode + '&fileName=' + name + '&fileType=' + type;
document.frmAssignments.target = '_self';
document.frmAssignments.submit();
}
function displayComments(assignmentid, obj)
{
var objParent = obj.offsetParent;
var left = objParent.offsetLeft;
var top = objParent.offsetTop;
var divElement = document.getElementById('divComments' + assignmentid);
if (divElement.style.display=='none')
{
var leftPoint = parseInt(left) - 400;
divElement.style.display = 'inline';
divElement.style.top = top;
divElement.style.left = leftPoint;
}
else
divElement.style.display='none';
}
</script>
</head>
<[COLOR=#FCE94F]body[/color] class="listbody">
<form name=[COLOR=#FCE94F]"frmAssignments[/color]" method="post" action="">
<table class="list" width="100%">
<thead class="listheading">
<th nowrap align="left">MP</th>
<th nowrap align="left">Due Date</th>
<th nowrap align="left">Day</th>
<th nowrap align="left">Course</th>
<th nowrap align="left">Teacher</th>
<th nowrap align="left">Category</th>
<th nowrap align="left">Assignment</th>
<th nowrap align="left">Grade</th>
<th nowrap align="left">Max</th>
<th nowrap align="center">%</th>
<th nowrap align="left">Prev</th>
<th nowrap align="left">Docs</th>
<th nowrap align="left"></th>
</thead>
[b]*********Header for table[/b]
[b]First Row[/b]
<tr class="listroweven" height="25px">
<td height="25px">MP2</td>
<td height="25px">11/27/2012</td>
<td height="25px">Tue</td>
<td height="25px">Adv Math Topics Trig A</td>
<td height="25px">Sheldon, Susan O</td>
<td height="25px">
HW
</td>
<td height="25px">
HW 4.1
</td>
<td height="25px" align="right">
<font color="#ff0000"></font>
</td>
<td height="25px" align="right">
0
</td>
<td align="right"></td>
<td height="25px" title="" align="center" ></td>
<td height="25px" title="Assignment Documents">
</td>
<td align="center">
<div id="divComments252017" style="display:none;position:absolute;width:400px;height:100px;background-color:#f5f5f5;border:1px solid #000000;">
<b><u>Comment from Sheldon, Susan O:</u></b><br>
Did not do
</div>
<img src="../../images/screens/gradebook/studentlist/sticky.gif" alt="" onclick="displayComments(252017, this);" style="cursor:help;" title="Click for Comment">
</td>
</tr>
[b]Second Row[/b]
<tr class="listrowodd" height="25px">
<td height="25px">MP2</td>
<td height="25px">11/28/2012</td>
<td height="25px">Wed</td>
<td height="25px">Adv Math Topics Trig A</td>
<td height="25px">Sheldon, Susan O</td>
<td height="25px">
HW
</td>
<td height="25px">
HW 4.2
</td>
<td height="25px" align="right">
<font color="#ff0000"></font>
</td>
<td height="25px" align="right">
0
</td>
<td align="right"></td>
<td height="25px" title="" align="center" ></td>
<td height="25px" title="Assignment Documents">
</td>
<td align="center">
<div id="divComments252021" style="display:none;position:absolute;width:400px;height:100px;background-color:#f5f5f5;border:1px solid #000000;">
<b><u>Comment from Sheldon, Susan O:</u></b><br>
Did not do
</div>
<img src="../../images/screens/gradebook/studentlist/sticky.gif" alt="" onclick="displayComments(252021, this);" style="cursor:help;" title="Click for Comment">
</td>
</tr>
[b] More Rows not shown[/b]
</table>
</form>
</body>
</html>
Using a For loop I can get the elements but none of the tags or names are helpful
Code:
For i = 0 To objHTML.Document.all.Length - 1
If TypeName(objHTML.Document.all(i)) = "HTMLTable" And _
InStr(objHTML.Document.all(i).innerText, "frmAssignments") > 0 Then
I suspect that the javascript may not be an element available to IE.
Any assistance in locating the table would be appreciated.
T.I.A
Blake