I am trying to make a program that can search for elements in a webpage using its source code. (i.e, first I will enter a webpage address to the application. suppose I enter www.google.com in the application. Then I will search for type="text"
and then the program should search source code of google.com and show me the number of type="text"
elements found in source code of Google).
I am using an external tool provided by iWEBTool
to get the source code.
The code is:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>My App</title>
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<style type="text/css">
#PageSource {
height: 367px;
width: 62%;
}
.auto-style1 {
width: 287px;
}
.auto-style2 {
width: 389px;
}
</style>
</head>
<body>
<h1 style="text-align:center">My App</h1>
<form method="get" name="pageform" action="http://www.iwebtool.com/tool/tools/code_viewer/code_viewer.php" target="pageframe" onsubmit="return validate(this);"><table border="0" style="border-collapse: collapse" width="100%"><tr>
<td width="956" height="91" valign="top"><br />
<table style="border-collapse: collapse" width="100%" class="tooltop" height="76"><tr>
<td><br />
<table border="0" style="border-collapse: collapse" width="100%" cellspacing="5"><tr>
<td height="28" class="auto-style1">Enter the website address :</td>
<td height="28" class="auto-style2"><br />
<font size="1">http://</font><input type="text" name="domain" size="26"></td>
<td height="28" width="391"><br />
<input type="submit" value="View!" style="float: left"></td>
</tr>
<tr>
<td height="21" class="auto-style1"> </td>
<td width="691" colspan="2" height="21" align="top"><font size="1"></font></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td width="956"><br />
<iframe name="pageframe" class="toolbot" frameborder="0" id="PageSource"><br />
</iframe></td>
</tr>
</table>
</form>
<script language="JavaScript">
function validate(theform) {
if (theform.domain.value == "") { alert("No Domain"); return false; }
return true;
}
<br />
</body>
</html>
Now, the source code gets successfully displayed in the web app and it is using an iframe to show the source code. I now want to find a way to search for tags inside the source code which is contained in iframe.
Should I load the content inside the iframe to a div to make the searching possible? Or is there any other way to accomplish searching?
Please help!