Sign in to follow this  
Followers 0
wilfrid100

Fail to copy HTML body content

6 posts in this topic

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'>

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

$oIE = _IECreate("http://www.1pengguna.com/11pengguna/index.php",0,1,1)

Share this post


Link to post
Share on other sites

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) ;

Share this post


Link to post
Share on other sites

_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.

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
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
Sign in to follow this  
Followers 0