Jump to content

quick question about INetGetSource and IEReadHTML


Recommended Posts

Guys,

I have a question. I am trying to get the html source on a webpage that has frames for a particular frame. I use the example in the help file for ieFrameGetCollection along with iePropertyGet and I'm displaying the info in a message box and it is returning the info back but it is a different source from when I do a control right click on the frame. Thats what I need! The source when I hold control and right click and view source. I tried using INetGetSource as well but no results. The way I got the url was, control right click and properties.

Unfortunately this is a cooperate website that only accessible from inside the facilities and not accessible outside the building. Do you guys have any advice on how I can get the true source I'm looking for. The one thats similar to the control right click view source.

Link to comment
Share on other sites

I excluded some of the code for privacy purposes but this is the part that I'm using to gather the frame info.

#include <Inet.au3>
#include <IE.au3>


$oie2 = _IECreate("http://dealer.toyota.com/Login.aspx?")
;
;
;Private Stuff here
;
;
MsgBox(0,"source",_INetGetSource("http://dealer.toyota.com/xxxxxxxxx/xxxxxxxxxxxx/xxxxxxxx/xxxxxxxx.aspx"))
Local $oFrames = _IEFrameGetCollection($oIE2)
Local $iNumFrames = @extended
For $i = 0 To ($iNumFrames - 1)
Local $oFrame = _IEFrameGetCollection($oIE2, $i)
MsgBox(0, "Location URL", _IEPropertyGet($oFrame, "locationurl"))
MsgBox(0, "Location Name", _IEPropertyGet($oFrame, "locationname"))
MsgBox(0, "Unique Element ID", _IEPropertyGet($oFrame, "uniqueid"))
MsgBox(0, "Inner HTML", _IEPropertyGet($oFrame, "innerhtml"))
MsgBox(0, "Outer HTML", _IEPropertyGet($oFrame, "outerhtml"))
Next
Link to comment
Share on other sites

I tried it and it is still showing a different source. I don't understand how it is doing this. Kinda weird. Smart but weird. It's a pain in the butt. The part that sucks for me is my script can run for the most part in the background but right now, it can't because I have to include the mouse movements and keystrokes. I tried using control send but with no luck with it running in the BG. Using the info tool, theres no ID for that frame.

Link to comment
Share on other sites

Are you actually righ-clicking on the frame, to view it's source?

It's basically like an embedded browser, so if you right click on the page (not the frame), the source is for the page, and references <iframe> or <frame> nodes, which are rendered by IE by it's src...if you right click on the frame (each frame has it's own source), you will view the source of only that frame (not the page)

check if this is what your looking for (outside the loop)

$string = _IEDocReadHTML($oIE2)
 ConsoleWrite($string & @CRLF)
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

_IEDocReadHTML : This function returns the document source after any client-side modifications (e.g. by AutoIt or by client-side Javascript). It may therefore be different than what is shown by the browser View Source or by _INetGetSource.

_INetGetSource : Returns what you get in the source through the browser. That is, its the html coded in the server.

So can you just give us the source which you are trying to retrieve and the one which you are getting ?

#include <Inet.au3>
#include <IE.au3>

;Change the URL
$oie2 = _IECreate("http://www.google.com")

FileWrite("Test1.au3", _IEDocReadHTML($oie2))
FileWrite("Test2.au3", _INetGetSource("http://www.google.com"))

ShellExecute("Test1.au3")
ShellExecute("Test2.au3")
Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

  • 2 months later...

Here is an  snip / example of what _IEDocReadHTML returns.

 

-----------------

<TR id=8443619 VIN="JTDKDTB35D1529675" chkcode="8" serial="D1529675" model="1201A" PendingRDRStatus="" RDRNo="0" move="1">
<TD style="CURSOR: hand" vAlign=top width=30 rowupdate="SmartIndicator" sonmouseout="top.oPopup.hide()" sonmouseover="top.DisplayColorCode()">
<TABLE style="BORDER-BOTTOM: black 1px solid; BORDER-LEFT: black 1px solid; BORDER-TOP: black 1px solid; BORDER-RIGHT: black 1px solid" id=tblSMI8443619 cellSpacing=0 cellPadding=0 width=25 bgColor=#ffffff height=15>
<TBODY>
<TR id=spam sid="8443619">
<TD bgColor=#ffb021 width=5 sonmouseout="top.oPopup.hide()" sonmouseover="top.DisplayColorCode()"><PRINTCOLORCODEIMG style="DISPLAY: none" src="/Portal/Shared/Images/Colors/FFB021.gif" height="14" width="6"></PRINTCOLORCODEIMG></TD>
<TD width=5 sonmouseout="top.oPopup.hide()" sonmouseover="top.DisplayColorCode()"></TD>
<TD width=5 sonmouseout="top.oPopup.hide()" sonmouseover="top.DisplayColorCode()"></TD>
<TD width=5 sonmouseout="top.oPopup.hide()" sonmouseover="top.DisplayColorCode()"></TD></TR></TBODY></TABLE></TD>
<TD vAlign=top width=40>145</TD>
<TD vAlign=top width=20 sonmouseout="oPopup.hide();gfCancelHoverTimer()" sonmouseover="&#13;&#10;            StatusChangeMouseOver('P');&#13;&#10;            ShowStatusChange(null,'LabelPredelivery')">P</TD>
<TD vAlign=top width=70 rowupdate="StockNo">000DT958</TD>
<TD style="CURSOR: progress" vAlign=top width=40 sonmouseout="oPopup.hide();gfCancelHoverTimer()" sonmouseover="ModelDescGet('1201A', '2013')">1201A</TD>
<TD vAlign=top width=40>2013</TD>
<TD style="CURSOR: progress" vAlign=top width=50 sonmouseout="oPopup.hide();gfCancelHoverTimer()" sonmouseover="ColorDescGet('0082', 'E', '1201A:2013:D1529675')">0082</TD>
<TD style="CURSOR: progress" vAlign=top width=50 sonmouseout="oPopup.hide();gfCancelHoverTimer()" sonmouseover="ColorDescGet('FE28', 'I', '1201A:2013:D1529675')">FE28</TD>
<TD vAlign=top width=142>JTDKDTB35D1529675</TD>
<TD vAlign=top width=60>D102CM56</TD>
<TD vAlign=top width=60>D1529675</TD>
<TD vAlign=top width=20>8</TD>
<TD style="CURSOR: progress" vAlign=top width=25 sonmouseout="oPopup.hide();gfCancelHoverTimer()" sonmouseover="CategoryDescGet('G')">G</TD>
<TD style="CURSOR: progress" id=ttip vAlign=top width=182 sonmouseout="gfCancelHoverTimer();" sonmouseover="DisplayAccessories()">FE PC CF</TD>
<TD vAlign=top width=50 SafetyConnect="1">N</TD>
<TD style="CURSOR: progress" vAlign=top width=55 sonmouseout="gfCancelHoverTimer();" sonmouseover="DisplayResiduals()" Residual="1">$$$</TD>
<TD style="CURSOR: progress" vAlign=top width=55 sonmouseout="oPopup.hide();gfCancelHoverTimer()" sonmouseover="ActivityStatusDescGet('.....')">.....</TD>
<TD vAlign=top width=63></TD>
<TD style="CURSOR: progress" vAlign=top width=42 sonmouseout="oPopup.hide();gfCancelHoverTimer();" sonmouseover="DisplayOrigDealerInfo('.....')">.....</TD>
<TD vAlign=top width=60>02/13/2013</TD>
<TD vAlign=top width=40>011</TD>
<TD vAlign=top width=60 align=right>20,495.00</TD>
<TD vAlign=top width=60 align=right modelcost="1">19,778.20</TD>
<TD vAlign=top width=15>Y</TD>
<TD vAlign=top width=15>N</TD>
<TD vAlign=top width=15>N</TD>
<TD vAlign=top width=15>Y</TD>
<TD vAlign=top width=140 rowupdate="CustomerName"></TD>
<TD vAlign=top width=200 rowupdate="Comments"></TD>
<TD></TD></TR>

 

---------------------------------------------

Below is the data that I need

    <!-- Store XML Data -->

    <XML id="xmlError"><Error/></XML>
    <XML id="xmlSearch"><Filter><DaysInStock/><DlrCode/><StatusChange/><StockNo/><ModelNo/><ModelYear/><ExteriorColorCode/><InteriorColorCode/><VIN/><TempSerialNo/><SerialNo/><CheckCode/><Category/><Accessories/><AccessoryCodeConcat/><SafetyConnect/><ResidualScreen/><ActivityStatus/><LocationArrivalDate/><OriginalDlrCode/><InvoiceDate/><AllocationNo/><ModelRetail1/><ModelCost/><DealerTrade/><HoldCost/><RentalCar/><DamageIndicator/><PDI/><Comments/><Distance/><DlrReg/><DlrDist/><ModelRetail/><MasterViewId>2</MasterViewId><CustomViewId/></Filter></XML>
    <XML id="xmlSearchCommitted"><Filter><DaysInStock/><DlrCode/><StatusChange/><StockNo/><ModelNo/><ModelYear/><ExteriorColorCode/><InteriorColorCode/><VIN/><TempSerialNo/><SerialNo/><CheckCode/><Category/><Accessories/><AccessoryCodeConcat/><SafetyConnect/><ResidualScreen/><ActivityStatus/><LocationArrivalDate/><OriginalDlrCode/><InvoiceDate/><AllocationNo/><ModelRetail1/><ModelCost/><DealerTrade/><HoldCost/><RentalCar/><DamageIndicator/><PDI/><Comments/><Distance/><DlrReg/><DlrDist/><ModelRetail/><MasterViewId>2</MasterViewId><CustomViewId/></Filter></XML>
    <XML id="xslFilter" src="/Portal/Shared/XSLTemplates/GenericSummaryFilter.xslt"></XML>
    
    
    <textarea id="txtXML" style="display:none;"><list><r c0="8443619" c1="P" c2="1201A" c3="2013" c4="0082" c5="FE28" c6="JTDKDTB35D1529675" c7="" c8="8" c9="Y" c10="N" c11="N" c12="Y" c13="D102CM56" c14="G" c15="" c16="1900-01-01" c17="" c18="011" c19="FE PC CF" c20="FE PC CF" c21="....." c22="02/13/2013" c23="20130213" c24="20495" c25="19778.20" c26="000DT958" c27="D1529675" c28="" c29="" c30="0" c31="0111637494" c32="T" c33="0" c34="0" c35="" c36="" c37="146" c38="In-Stock" c39="" c40="" c41="" c42="" c43="" c44="0" c45="" c47="1201" c48="G"

------------------------------------

Is there anyway that I can get what I need using _IEDocReadHTML? If I could get what I need, the entire script could run in the background.

Link to comment
Share on other sites

The DOM (and thus the _IE functions) only recognize the current state of the document structure (after client-side processing).

WinHTTP or XMLHttpRequest could perhaps be used to request the page source from the webserver.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Just have a look if it helps in any case, XML UDF would surely be better. :)

$s_Data = FileRead("File.txt")
$s_Required = StringRegExpReplace($s_Data, "(?s).*?<XML", "<XML", 1)

ConsoleWrite($s_Required & @CRLF)

;File.txt contains
#cs
    <TR id=8443619 VIN="JTDKDTB35D1529675" chkcode="8" serial="D1529675" model="1201A" PendingRDRStatus="" RDRNo="0" move="1">
    <TD style="CURSOR: hand" vAlign=top width=30 rowupdate="SmartIndicator" sonmouseout="top.oPopup.hide()" sonmouseover="top.DisplayColorCode()">
    <TABLE style="BORDER-BOTTOM: black 1px solid; BORDER-LEFT: black 1px solid; BORDER-TOP: black 1px solid; BORDER-RIGHT: black 1px solid" id=tblSMI8443619 cellSpacing=0 cellPadding=0 width=25 bgColor=#ffffff height=15>
    <TBODY>
    <TR id=spam sid="8443619">
    <TD bgColor=#ffb021 width=5 sonmouseout="top.oPopup.hide()" sonmouseover="top.DisplayColorCode()"><PRINTCOLORCODEIMG style="DISPLAY: none" src="/Portal/Shared/Images/Colors/FFB021.gif" height="14" width="6"></PRINTCOLORCODEIMG></TD>
    <TD width=5 sonmouseout="top.oPopup.hide()" sonmouseover="top.DisplayColorCode()"></TD>
    <TD width=5 sonmouseout="top.oPopup.hide()" sonmouseover="top.DisplayColorCode()"></TD>
    <TD width=5 sonmouseout="top.oPopup.hide()" sonmouseover="top.DisplayColorCode()"></TD></TR></TBODY></TABLE></TD>
    <TD vAlign=top width=40>145</TD>
    <TD vAlign=top width=20 sonmouseout="oPopup.hide();gfCancelHoverTimer()" sonmouseover="&#13;&#10;            StatusChangeMouseOver('P');&#13;&#10;            ShowStatusChange(null,'LabelPredelivery')">P</TD>
    <TD vAlign=top width=70 rowupdate="StockNo">000DT958</TD>
    <TD style="CURSOR: progress" vAlign=top width=40 sonmouseout="oPopup.hide();gfCancelHoverTimer()" sonmouseover="ModelDescGet('1201A', '2013')">1201A</TD>
    <TD vAlign=top width=40>2013</TD>
    <TD style="CURSOR: progress" vAlign=top width=50 sonmouseout="oPopup.hide();gfCancelHoverTimer()" sonmouseover="ColorDescGet('0082', 'E', '1201A:2013:D1529675')">0082</TD>
    <TD style="CURSOR: progress" vAlign=top width=50 sonmouseout="oPopup.hide();gfCancelHoverTimer()" sonmouseover="ColorDescGet('FE28', 'I', '1201A:2013:D1529675')">FE28</TD>
    <TD vAlign=top width=142>JTDKDTB35D1529675</TD>
    <TD vAlign=top width=60>D102CM56</TD>
    <TD vAlign=top width=60>D1529675</TD>
    <TD vAlign=top width=20>8</TD>
    <TD style="CURSOR: progress" vAlign=top width=25 sonmouseout="oPopup.hide();gfCancelHoverTimer()" sonmouseover="CategoryDescGet('G')">G</TD>
    <TD style="CURSOR: progress" id=ttip vAlign=top width=182 sonmouseout="gfCancelHoverTimer();" sonmouseover="DisplayAccessories()">FE PC CF</TD>
    <TD vAlign=top width=50 SafetyConnect="1">N</TD>
    <TD style="CURSOR: progress" vAlign=top width=55 sonmouseout="gfCancelHoverTimer();" sonmouseover="DisplayResiduals()" Residual="1">$$$</TD>
    <TD style="CURSOR: progress" vAlign=top width=55 sonmouseout="oPopup.hide();gfCancelHoverTimer()" sonmouseover="ActivityStatusDescGet('.....')">.....</TD>
    <TD vAlign=top width=63></TD>
    <TD style="CURSOR: progress" vAlign=top width=42 sonmouseout="oPopup.hide();gfCancelHoverTimer();" sonmouseover="DisplayOrigDealerInfo('.....')">.....</TD>
    <TD vAlign=top width=60>02/13/2013</TD>
    <TD vAlign=top width=40>011</TD>
    <TD vAlign=top width=60 align=right>20,495.00</TD>
    <TD vAlign=top width=60 align=right modelcost="1">19,778.20</TD>
    <TD vAlign=top width=15>Y</TD>
    <TD vAlign=top width=15>N</TD>
    <TD vAlign=top width=15>N</TD>
    <TD vAlign=top width=15>Y</TD>
    <TD vAlign=top width=140 rowupdate="CustomerName"></TD>
    <TD vAlign=top width=200 rowupdate="Comments"></TD>
    <TD></TD></TR>
    
    
    ---------------------------------------------
    
    Below is the data that I need
    
    <!-- Store XML Data -->
    
    <XML id="xmlError"><Error/></XML>
    <XML id="xmlSearch"><Filter><DaysInStock/><DlrCode/><StatusChange/><StockNo/><ModelNo/><ModelYear/><ExteriorColorCode/><InteriorColorCode/><VIN/><TempSerialNo/><SerialNo/><CheckCode/><Category/><Accessories/><AccessoryCodeConcat/><SafetyConnect/><ResidualScreen/><ActivityStatus/><LocationArrivalDate/><OriginalDlrCode/><InvoiceDate/><AllocationNo/><ModelRetail1/><ModelCost/><DealerTrade/><HoldCost/><RentalCar/><DamageIndicator/><PDI/><Comments/><Distance/><DlrReg/><DlrDist/><ModelRetail/><MasterViewId>2</MasterViewId><CustomViewId/></Filter></XML>
    <XML id="xmlSearchCommitted"><Filter><DaysInStock/><DlrCode/><StatusChange/><StockNo/><ModelNo/><ModelYear/><ExteriorColorCode/><InteriorColorCode/><VIN/><TempSerialNo/><SerialNo/><CheckCode/><Category/><Accessories/><AccessoryCodeConcat/><SafetyConnect/><ResidualScreen/><ActivityStatus/><LocationArrivalDate/><OriginalDlrCode/><InvoiceDate/><AllocationNo/><ModelRetail1/><ModelCost/><DealerTrade/><HoldCost/><RentalCar/><DamageIndicator/><PDI/><Comments/><Distance/><DlrReg/><DlrDist/><ModelRetail/><MasterViewId>2</MasterViewId><CustomViewId/></Filter></XML>
    <XML id="xslFilter" src="/Portal/Shared/XSLTemplates/GenericSummaryFilter.xslt"></XML>
    
    
    <textarea id="txtXML" style="display:none;"><list><r c0="8443619" c1="P" c2="1201A" c3="2013" c4="0082" c5="FE28" c6="JTDKDTB35D1529675" c7="" c8="8" c9="Y" c10="N" c11="N" c12="Y" c13="D102CM56" c14="G" c15="" c16="1900-01-01" c17="" c18="011" c19="FE PC CF" c20="FE PC CF" c21="....." c22="02/13/2013" c23="20130213" c24="20495" c25="19778.20" c26="000DT958" c27="D1529675" c28="" c29="" c30="0" c31="0111637494" c32="T" c33="0" c34="0" c35="" c36="" c37="146" c38="In-Stock" c39="" c40="" c41="" c42="" c43="" c44="0" c45="" c47="1201" c48="G"
#ce

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...