wilfrid100 Posted March 27, 2013 Share Posted March 27, 2013 I'm writing a script for auto-query and save the item pricelist as .csv file, so far the script able to auto-query one item but fail to copy out the item HTML body content.The variable $read seem like can not read the HTML body content (show in blue colour html code). Appreciate someone can give me a hand on this.thanks#include <IE.au3> #include <Array.au3> $oIE = _IECreate("[url="http://www.1pengguna.com/11pengguna/index.php"]http://www.1pengguna.com/11pengguna/index.php[/url]") $oInput = _IEGetObjByName($oIE, "KodBrg") _IEFormElementOptionselect($oInput, "ANGGUR MERAH BERBIJI-(1kg)" , 1, "byText") $oInput = _IEGetObjByName($oIE, "negeri") _IEFormElementOptionselect($oInput, "SELANGOR" , 1, "byText") $shtml = _IEFormImageClick($oIE, "/11pengguna/template/1pengguna/images/cariharga_bm.png", "src") ;result show ok in webpage $read = _IEBodyReadHTML($shtml) ;not able to read HTML body content $oIE2 = _IECreate() _IEBodyWriteHTML($oIE2, $read) ;result with 0 <div id="content"><div class="font"> <table cellspacing="1" cellpadding="1" width='100%' border='0' cellpadding='2' cellspacing='1' class='box2 light2'> <tr bgColor=''#EEEEEE'><td colspan='5'>TARIKH HARGA : 26-03-2013 </td></tr><tr bgColor='#EEEEEE'><td colspan='5'>NAMA BARANG : PEPSI-1 TIN </td></tr><tr bgcolor='#FFFFCC'><td align='center'>BIL.</td> <td width='1'></td><td align='center'>NAMA/ALAMAT PREMIS PERNIAGAAN</td><td align='center'>KATEGORI PREMIS</td><td align='center'>HARGA (RM)</td></tr><tr bgColor='white'><td align='center'>1.</td> <td><img src='/11pengguna/module/mysearch/images/drink-bm.png'> </td> <td>[color=#0000cd]99 SPEED MART SDN BHD<br>BRANCH PANDAMARANNO 153 & 155 (GROUND FLOOR)JLN AH CHOO, PANDAMARAN42000 KLANG SELANGOR</td><td align='center'>KEDAI SERBANEKA (24 JAM)</td><td align='center'>1.80</td></[/color]tr><tr bgColor='white'><td align='center'>2.</td> <td><img src='/11pengguna/module/mysearch/images/drink-bm.png'> </td> [color=#0000ff]<td>7 ELEVEN SELAYANG JAYA<br>TAMAN SELAYANG JAYAKEPONGSELANGOR DE</td><td align='center'>KEDAI SERBANEKA (24 JAM)</td><td align='center'>1.80</td></[/color]tr><tr bgColor='white'><td align='center'> Link to comment Share on other sites More sharing options...
DaleHohm Posted March 27, 2013 Share Posted March 27, 2013 It may be as simple as adding _IELoadWait prior to your _IEBodyReadHTML If not, look for Frames. 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 More sharing options...
StefanoVR Posted March 27, 2013 Share Posted March 27, 2013 $oIE = _IECreate("http://www.1pengguna.com/11pengguna/index.php",0,1,1) Link to comment Share on other sites More sharing options...
wilfrid100 Posted March 28, 2013 Author Share Posted March 28, 2013 The problem not solved and _IEBodyWriteHTML still give me "0" result. The _IEFormImageClick() able to display in IE browser but I have no idea why _IEBodyReadHTML not able read the HTML (outcome) I tried save the HTML (outcome) to local and then try run _IEBodyReadHTML(), the _IEBodyReadHTML() able result the correct HTML: $read = _IEBodyReadHTML(_IELoadWait(C:Documents and SettingswilfridDesktophtml.htm)) #include <IE.au3> #include <Array.au3> $oIE = _IECreate("http://www.1pengguna.com/11pengguna/index.php",0,1,1) $oInput = _IEGetObjByName($oIE, "KodBrg") _IEFormElementOptionselect($oInput, "ANGGUR MERAH BERBIJI-(1kg)" , 1, "byText") $oInput = _IEGetObjByName($oIE, "negeri") _IEFormElementOptionselect($oInput, "SELANGOR" , 1, "byText") $shtml = _IEFormImageClick($oIE, "/11pengguna/template/1pengguna/images/cariharga_bm.png", "src") $read = _IEBodyReadHTML(_IELoadWait($shtml)) ;not able to read HTML body content $oIE2 = _IECreate() _IEBodyWriteHTML($oIE2, $read) ; Link to comment Share on other sites More sharing options...
jdelaney Posted March 28, 2013 Share Posted March 28, 2013 _IELoadWait doesn't return the dom object, so it shouldn't be nested in the _IEBodyReadHTML...look in the helpfile for 'returns' from functions 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 More sharing options...
wilfrid100 Posted March 30, 2013 Author Share Posted March 30, 2013 Thanks for all of you, you guys had pointing out my mistake. solution: Instead of using _IELoadWait or other reading HTML command, I replace _IEBodyHTML() ref obj to $oIE rather than $shtml. final code: $oIE = _IECreate("http://www.1pengguna.com/11pengguna/index.php") $oInput = _IEGetObjByName($oIE, "KodBrg") _IEFormElementOptionselect($oInput, "ANGGUR MERAH BERBIJI-(1kg)" , 1, "byText") $oInput = _IEGetObjByName($oIE, "negeri") _IEFormElementOptionselect($oInput, "SELANGOR" , 1, "byText") _IEFormImageClick($oIE, "/11pengguna/template/1pengguna/images/cariharga_bm.png", "src") ;result show ok in webpage $read = _IEBodyReadHTML($oIE) $oIE2 = _IECreate() _IEBodyWriteHTML($oIE2, $read) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now