|
-
Oct 26th, 2012, 06:38 PM
#1
Thread Starter
New Member
WebBrowser Source Code
I am barely new with the webbrowser, webrequest & webresponse. I am now trying to capture the source code on the webbrowser .
I had tried to use webbrowser.documentText and only get the partial source code – I guess it is the main frame and there are some other frames or something else that preventing me to get the source. I can view the source on the IE/Firefox but, with clicking at the different area of the page.
Below is the source I catch with webbrowser.documentText: I really need someone to help me out -- I had try for two weeks without success. 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>SigmaQuest Menu</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Pragma" content="no-cache" />
<link rel="stylesheet" href="css/style.css?cache=0911.18"/>
<link rel="stylesheet" href="css/menu/menu.css?cache=0911.18"/>
<script type="text/javascript" src="script/DateChecker.js?cache=0911.18"></script>
<script type="text/javascript" src="script/FirstFocus.js?cache=0911.18"></script>
<script type="text/javascript" src="script/MM_openBrWindow.js?cache=0911.18"></script>
<script type="text/javascript" src="script/goToURL.js?cache=0911.18"></script>
<script type="text/javascript" src="script/UpdateSubmit.js?cache=0911.18"></script>
<script type="text/javascript" src="script/MM_findObj.js?cache=0911.18"></script>
<script type="text/javascript">
function setLoading(url)
{
var img = document.getElementById("progress");
if(img)
{
img.src = url;
}
}
function show_loading()
{
setLoading('img/dashboard/indicator.gif');
}
function hide_loading()
{
setLoading('img/dashboard/blank.png');
}
// This function first determines which the frame that contains dataselector form, then submits it.
function CheckAndsubmit()
{
if (top.content.main.pane.mainChart)
{
top.content.main.pane.mainChart.submit();
}
else if (top.content.main.pane)
{
top.content.main.pane.submit();
}
}
function youraccount()
{
var mywindow = window.open('User.do?op=editMyAccount&id=10122103384', 'windName','width=500,height=200,alwaysRaised=true,menubar=0,toolbar=0,scrollbars=1,status=1,resizab le=1');
var topWidow = top;
while(topWidow.opener != null)
{
topWidow = topWidow.opener.top;
}
topWidow.data.updateWindowArray(mywindow);
mywindow.focus();
}
function serversettings()
{
var mywindow = window.open('ServerSetting.do', 'serversetting','alwaysRaised=true,menubar=0,toolbar=0,scrollbars=1,status=1,resizable=1');
var topWidow = top;
while(topWidow.opener != null)
{
topWidow = topWidow.opener.top;
}
topWidow.data.updateWindowArray(mywindow);
mywindow.focus();
}
function yoursettings()
{
var mywindow = window.open('UserSetting.do', 'usersetting','alwaysRaised=true,menubar=0,toolbar=0,scrollbars=1,status=1,resizable=1');
var topWidow = top;
while(topWidow.opener != null)
{
topWidow = topWidow.opener.top;
}
topWidow.data.updateWindowArray(mywindow);
mywindow.focus();
}
function showQueries()
{
var aImg = MM_findObj("ALERT_IMG");
var loc = aImg.src;
if(loc.indexOf('warning') != -1)
{
var mywindow = window.open('main/cache/ConnectionPool.jsp', 'usersetting','alwaysRaised=true,menubar=0,toolbar=0,scrollbars=1,status=1,resizable=1');
var topWidow = top;
while(topWidow.opener != null)
{
topWidow = topWidow.opener.top;
}
topWidow.data.updateWindowArray(mywindow);
mywindow.focus();
}
}
var selectedDivName = 'subMenu221';
//For storing subMenu Ids
var subMenuIdArray = new Array(
'subMenu221',
'subMenu222',
'subMenu223',
'subMenu224',
'subMenu225',
'subMenu233',
'subMenu234',
'subMenu227',
'subMenu235',
'subMenu228'
);
function selectSubMenu(divName, contextChart, menu, subMenu, targetUrl)
{
show_loading();
//deselect all subMenus
for (var i=0; i < subMenuIdArray.length; i++)
{
var id = subMenuIdArray[i];
document.getElementById(id).className = '';
}
// select the active subMenu
document.getElementById(divName).className='selected';
//---- disable Update for Process Control and search attachment
if(selectedDivName == "")
{
return;
}
var relativeBaseURL = '/harmonic/';
var relativeTargetURL = relativeBaseURL + targetUrl;
// (SA-149) if we don't have the tree frame (e.g. we're in MTF) and we're going to need it, then load it up!
// NOTE: THIS DID NOT WORK, LEAVING THE CODE HERE FOR FUTURE REFERENCE.
// SOLUTIONS:
// 1) Complete rewrite
// 2) Force user to go to UR List first
// 3) Refresh entire page
// 4) New custom action to load any analysis subtab correctly???
//if (!(top.content.main.treeFrameset) && menu == 'analysis' && subMenu != 'manualtestforms')
//{
// contextChart, menu, submenu
//var mainURLDest = relativeBaseURL + '/main/screens/unitreport/Frame.jsp?contextChart=' + contextChart + '&menu='+ menu + '&subMenu=' + subMenu;
//top.content.main.document.location = mainURLDest;
//return;
//top.content.main.document.location = relativeTargetURL + '?contextChart=' + contextChart + '&menu='+ menu + '&subMenu=' + subMenu;
//top.content.main.document.location = 'mainFrame.do?contextChart=' + contextChart + '&menu='+ menu + '&subMenu=' + subMenu;
//}
//else
if(subMenu == 'reports')
{
if( top.content.main.treeFrameset )
top.content.main.pane.document.location = 'UnitReportListAction.do?contextChart=' + contextChart + '&menu='+ menu + '&subMenu=' + subMenu;
else
top.content.main.document.location = relativeTargetURL + '?contextChart=' + contextChart + '&menu='+ menu + '&subMenu=' + subMenu;
}
else if(subMenu == 'charts' || subMenu == 'wizards' || subMenu == 'SEARCHATTACHMENT' || subMenu == 'ERRORANALYSIS')
{
if( top.content.main.treeFrameset )
top.content.main.pane.document.location = 'ChartsAction.do?contextChart=' + contextChart + '&menu='+ menu + '&subMenu=' + subMenu;
else
top.content.main.document.location = relativeTargetURL + '?contextChart=' + contextChart + '&menu='+ menu + '&subMenu=' + subMenu;
}
else if(subMenu == 'manualtestforms' || (menu == 'genealogy' && (subMenu == 'genealogyreports' || subMenu == 'manualgenealogyforms')))
{
top.content.main.document.location = relativeTargetURL;
}
else
{
if(menu == 'analysis')
{
if( !top.content.main.treeFrameset )
{
relativeTargetURL = relativeBaseURL + "/main/screens/unitreport/Frame.jsp";
top.content.main.document.location = relativeTargetURL + '?contextChart=' + contextChart + '&menu='+ menu + '&subMenu=' + subMenu;
}
else if(top.content.main.pane)
{
top.content.main.pane.document.location = 'mainFrame.do?contextChart=' + contextChart + '&menu='+ menu + '&subMenu=' + subMenu;
}
else if(subMenu == 'parametrics' || subMenu == 'processControl')
{
top.content.main.document.location = 'menu.do?rnd=0.8698848005107441&contextChart=' + contextChart + '&menu='+ menu ;
}
}
else
{
if(targetUrl.indexOf('?') < 0)
{
top.content.main.document.location = relativeTargetURL + '?contextChart=' + contextChart + '&menu='+ menu + '&subMenu=' + subMenu;
}
else
{
top.content.main.document.location = relativeTargetURL + '&contextChart=' + contextChart + '&menu='+ menu + '&subMenu=' + subMenu;
}
}
}
if (top.content.main.treeFrameset)
{
// if tree exists, refresh the typeofdata frame to the new context
top.content.main.treeFrameset.TypeofDataFrame.document.location = 'TypeOfDataFrame.do?contextChart=' + contextChart + '&menu='+ menu + '&subMenu=' + subMenu;
top.content.main.treeFrameset.DateFrame.showHideUpdateButton(subMenu);
}
selectedDivName = divName;
}
function doLogout()
{
if (top.data && top.data.closeAllwindows)
top.data.closeAllwindows();
top.location = 'logout.do';
}
function init()
{
show_loading();
goToTopURL('/harmonic/mainFrame.do?contextChart=reports&menu=analysis&subMenu=reports&rand=0.2693773525492823');
}
function help()
{
w=window.open("help/manuals/wrapper/custom/FrameSet.jsp?id=h", "help", "width=800,height=600,scrollbars=yes,resizable=yes,status=no,location=no,toolbar=no,menubar=no") ;
w.focus();
}
</script>
</head>
<body onload="javascript:init()">
<div class="container">
<div class="logo" style="float: left"><img alt="Camstar Logo" src="img/logo.jpg" onclick="javascript:window.open('http://www.camstar.com');"/></div>
<div class="header">
<p><span class="">Welcome, SheauYun Ung!</span> [ <a class="logout" href="javascript:doLogout()">logout</a> ]</p>
<ul class="menu">
<li><a class="" href="javascript:youraccount();">Profile</a></li>
<li><a class="" href="javascript:yoursettings();">User Settings</a></li>
<li><a class="" href="javascript:help();">Help</a></li>
<li><img id="progress" src="img/dashboard/blank.png" /></li>
</ul>
</div>
<ul class="menu main-menu">
<li >
<a href="/harmonic/menu.do?menu=dashboard&rand=0.7961243198739852 " onclick="top.data.startRequest();" >
Dashboard
</a>
</li>
<li class="selected">
<a href="/harmonic/menu.do?menu=analysis&rand=0.3841190017120414 " onclick="top.data.startRequest();" class="selected">
Supply Chain
</a>
</li>
<li >
<a href="/harmonic/menu.do?menu=Repair+Analysis&rand=0.2874393868121573 " onclick="top.data.startRequest();" >
Repair
</a>
</li>
<li >
<a href="/harmonic/menu.do?menu=RMA+Analysis&rand=0.002386673588599786 " onclick="top.data.startRequest();" >
RMA
</a>
</li>
</ul>
<ul class="menu sub-menu">
<li></li>
<li>
<a href="#" id="subMenu221" class="selected"
onclick="javascript:selectSubMenu('subMenu221', 'reports', 'analysis', 'reports', '/main/screens/unitreport/Frame.jsp')">
Summary
</a>
</li>
<li>
<a href="#" id="subMenu222"
onclick="javascript:selectSubMenu('subMenu222', 'charts', 'analysis', 'charts', '/main/screens/unitreport/Frame.jsp')">
Charts
</a>
</li>
<li>
<a href="#" id="subMenu223"
onclick="javascript:selectSubMenu('subMenu223', 'parametrics', 'analysis', 'parametrics', '/main/screens/chart/ParametricFrame.jsp')">
Parametrics
</a>
</li>
<li>
<a href="#" id="subMenu224"
onclick="javascript:selectSubMenu('subMenu224', 'wizards', 'analysis', 'wizards', '/main/screens/unitreport/Frame.jsp')">
Wizards
</a>
</li>
<li>
<a href="#" id="subMenu225"
onclick="javascript:selectSubMenu('subMenu225', 'processcontrol', 'analysis', 'processControl', '/SpcFrameAction.do')">
Process Control
</a>
</li>
<li>
<a href="#" id="subMenu233"
onclick="javascript:selectSubMenu('subMenu233', 'management', 'analysis', 'management', '/TestSummaryAllReportAction.do?o=s')">
Reports
</a>
</li>
<li>
<a href="#" id="subMenu234"
onclick="javascript:selectSubMenu('subMenu234', 'pbreports', 'analysis', 'pbreports', '/OneClickReport.do?method=begin')">
Push Button Report
</a>
</li>
<li>
<a href="#" id="subMenu227"
onclick="javascript:selectSubMenu('subMenu227', 'pfv', 'analysis', 'pfv', '/pfv/pfventry.do')">
Process Flow
</a>
</li>
<li>
<a href="#" id="subMenu235"
onclick="javascript:selectSubMenu('subMenu235', 'manualtestforms', 'analysis', 'manualtestforms', '/main/screens/manualtestforms/Frame.jsp')">
Test Forms
</a>
</li>
<li>
<a href="#" id="subMenu228"
onclick="javascript:selectSubMenu('subMenu228', 'timeanalysis', 'analysis', 'timeanalysis', '/TimeAnalysis/TimeAnalysisEntry.do')">
Time Analysis
</a>
</li>
<li></li>
</ul>
</div>
</body>
</html>
There are suggestions of using innerhtml/outerhtml but, it will not works too…. I only get the following for all three frames that appear on the main source 
<BODY onbeforeunload=sendLogout();></BODY>
<FRAME noResize src="/harmonic/menu.do" name=menu scrolling=no><FRAME src="/harmonic/mainFrame.do" name=main>
<FRAMESET frameSpacing=0 frameBorder=0 rows=87,*><FRAME noResize src="/harmonic/menu.do" name=menu scrolling=no><FRAME src="/harmonic/mainFrame.do" name=main></FRAMESET>
<BODY></BODY>
-
Oct 28th, 2012, 12:13 AM
#2
Thread Starter
New Member
Re: WebBrowser Source Code
No one can help?? I really need some helps here....
-
Oct 29th, 2012, 05:41 PM
#3
Re: WebBrowser Source Code
Each frame has its own 'Document':
vb.net Code:
WebBrowser1.Document.Window.Frames(1).Document.Body.OuterHtml
-
Nov 1st, 2012, 11:14 PM
#4
Thread Starter
New Member
Re: WebBrowser Source Code
I tried below but only getting something below... How? 
Me.WebBrowser1.Document.Window.Frames("data").Document.Body.OuterHtml
Me.WebBrowser1.Document.Window.Frames("data").Document.Body.InnerHtml
Me.WebBrowser1.Document.Window.Frames("content").Document.Body.OuterHtml
Me.WebBrowser1.Document.Window.Frames("content").Document.Body.InnerHtml
<BODY onbeforeunload=sendLogout();></BODY>
<FRAME noResize src="/harmonic/menu.do" name=menu scrolling=no><FRAME src="/harmonic/mainFrame.do" name=main>
<FRAMESET frameSpacing=0 frameBorder=0 rows=87,*><FRAME noResize src="/harmonic/menu.do" name=menu scrolling=no><FRAME src="/harmonic/mainFrame.do" name=main></FRAMESET>
<BODY></BODY>
-
Nov 2nd, 2012, 03:24 AM
#5
Re: WebBrowser Source Code
WebBrowser1.Document.Window.Frames returns an array containing all the frames of a web page. You can get the frame you are interested in by using its position in the array.
Code:
'see how many frames are there
MessageBox.Show(WebBrowser1.Document.Window.Frames().Count.ToString)
'show the source code of each frame
For i As Integer = 0 To WebBrowser1.Document.Window.Frames.Count - 1
MessageBox.Show("Frame number: " & i & vbCrLf & vbCrLf & WebBrowser1.Document.Window.Frames(i).Document.Body.OuterHtml)
Next
-
Nov 3rd, 2012, 12:05 AM
#6
Thread Starter
New Member
Re: WebBrowser Source Code
 Originally Posted by Half
WebBrowser1.Document.Window.Frames returns an array containing all the frames of a web page. You can get the frame you are interested in by using its position in the array.
Code:
'see how many frames are there
MessageBox.Show(WebBrowser1.Document.Window.Frames().Count.ToString)
'show the source code of each frame
For i As Integer = 0 To WebBrowser1.Document.Window.Frames.Count - 1
MessageBox.Show("Frame number: " & i & vbCrLf & vbCrLf & WebBrowser1.Document.Window.Frames(i).Document.Body.OuterHtml)
Next
Half,
Thank you for reply. No luck with it. I Am getting something below:
Frame number: 0
<BODY onbeforeunload=sendLogout();></BODY>
Frame number: 1
<FRAMESET frameSpacing=0 frameBorder=0 rows=87,*><FRAME noResize src="/harmonic/menu.do" name=menu scrolling=no><FRAME src="/harmonic/mainFrame.do" name=main></FRAMESET>
Frame number: 2
<BODY></BODY>
-
Nov 3rd, 2012, 03:33 PM
#7
Re: WebBrowser Source Code
Try with "InnerHtml" 
You wait for everything to completely load first, right?
-
Nov 4th, 2012, 02:43 AM
#8
Thread Starter
New Member
Re: WebBrowser Source Code
 Originally Posted by Half
Try with "InnerHtml"
You wait for everything to completely load first, right?
Yes. you are right. i am running the command after the page completely loaded... innerhtml does not good either... nothing on the 1st and 3rd frame..
Frame number: 0
Frame number: 1
<FRAME noResize src="/harmonic/menu.do" name=menu scrolling=no><FRAME src="/harmonic/mainFrame.do" name=main>
Frame number: 2
-
Nov 4th, 2012, 01:15 PM
#9
Re: WebBrowser Source Code
Well you are getting exactly what you're asking for. The Frame html. If you want anything beyond that then you need to load the frame sources themselves.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Nov 5th, 2012, 08:42 PM
#10
Re: WebBrowser Source Code
Without the actual url we can only blindly try to offer you a solution. It could be a frame in an iframe, an ajax thing, an html fetching call from within a java applet.
-
Nov 7th, 2012, 01:13 AM
#11
Thread Starter
New Member
Re: WebBrowser Source Code
dunfiddlin, what do you mean with loading the frame sources themselves? How to do that?
Half, I think you probably is right about the java things. I think the frame were run by java script or something like that. That is why I am copying the source (on the 1st post) I get by right clicking the browser... If the html is called from within a java applet, what should I do next?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|