AutoHotkey Community

It is currently May 27th, 2012, 6:14 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 29 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: March 4th, 2010, 4:01 am 
Offline

Joined: September 18th, 2004, 5:32 am
Posts: 133
Anyone...? :cry:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 4:16 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
this problem is because once you retreive something with iweb_getdomobj its just text and no longer part of a DOM

Code:
tbldoc:=iWeb_Txt2Doc("<table>" tbl "</table>")

then you can use the table parsing function

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 4:21 am 
Offline

Joined: September 18th, 2004, 5:32 am
Posts: 133
Oh I forgot -- I also tried

Quote:
tbl:=COM_Invoke(pwb,"document.getElementsByTagName","data")
i := COM_Invoke(tbl,"length")


But "i" ends up with a value of 0

And the value of tbl increments each time I run the script, e.g. 3123340 to 3123372 to 3124202 to 3124996 (what the heck does that mean??)

And I tried
Code:
tbl:=iWeb_getDomObj(pwb,"267")   ;   The table of member links
msgbox % COM_Invoke(tbl,"cells[]")
msgbox % COM_Invoke(tbl,"rows[]")


I got
Quote:
COM Error Notification
Function Name: "cells[]"
ERROR: The COM Object may not be a valid Dispatch Object!


Same error message for "rows[]", "cells[0] and "rows[0]"...


Grrrrr.....!@$!#@% :x


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 4:26 am 
Offline

Joined: September 18th, 2004, 5:32 am
Posts: 133
Thanks Tank - is there a way to just use the table parsing function directly?

Either way, as I mentioned earlier, I could not find any clue how to use the table parsing function. I looked up pDisp... on the web and ... over my head. I've put a ton of effort into getting where I am now ... 2 days ago, I didn't know what a DOM or a COM or a tag or an element were...
head is spinning with all I've learned... getting discouraged

I would appreciate any help wrapping this thing up :)
Please :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 5:05 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
SAbboushi wrote:
Oh I forgot -- I also tried
Code:
tbl:=COM_Invoke(pwb,"document.getElementsByTagName","data")
i := COM_Invoke(tbl,"length")

But "i" ends up with a value of 0
The first line returns a collection of all elements who's tag is "data", and the second line tells you how many elements were returned. I'm not surprised there are 0 elements with the html tag "data" :wink: .

SAbboushi wrote:
And the value of tbl increments each time I run the script, e.g. 3123340 to 3123372 to 3124202 to 3124996 (what the heck does that mean??)
This number is the value of the pointer to the COM object - which means nothing to us other that it's a valid COM object.

SAbboushi wrote:
... 2 days ago, I didn't know what a DOM or a COM or a tag or an element were...
tank's iWeb library is a great tool, but if you're leaning DOM & COM, why not try to parse the table without it? You'll learn more overall :wink: . Do you have an example table?

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 5:36 am 
Offline

Joined: September 18th, 2004, 5:32 am
Posts: 133
Hi Jethrow - thanks for joining! I've read a lot of your stuff and thanks for all your contributions as well.

1) Sample Table with links I need to collect

Code:
<TBODY>
<TR>
<TD>&nbsp;</TD>
<TD vAlign=top noWrap><A onclick="NewWindow(this.href,'nameinfo','565','250','yes');return false;" href="listallmemberpopup.cfm?id=5466&amp;q=A&amp;r=B&amp;startrec=1"><FONT color=#00382b font="Arial">Abboushi, Sam </FONT></A></TD>
<TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
<TD>&nbsp;</TD>
<TD vAlign=top noWrap><A onclick="NewWindow(this.href,'nameinfo','565','250','yes');return false;" href="listallmemberpopup.cfm?id=3412&amp;q=A&amp;r=B&amp;startrec=1"><FONT color=#00382b font="Arial">Abby, Victor </FONT></A></TD>
<TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD></TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign=top noWrap><A onclick="NewWindow(this.href,'nameinfo','565','250','yes');return false;" href="listallmemberpopup.cfm?id=6751&amp;q=A&amp;r=B&amp;startrec=1"><FONT color=#00382b font="Arial">Albert, Charles </FONT></A></TD>
<TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
<TD>&nbsp;</TD>
<TD vAlign=top noWrap><A onclick="NewWindow(this.href,'nameinfo','565','250','yes');return false;" href="listallmemberpopup.cfm?id=2165&amp;q=A&amp;r=B&amp;startrec=1"><FONT color=#00382b font="Arial">Acorn, Rose </FONT></A></TD>
<TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD></TR>
...


2) Sample data record for first link (i.e. Abboushi, Sam
listallmemberpopup.cfm?id=5466&amp;q=A&amp;r=B&amp;startrec=1)

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><META content="IE=5.0000" http-equiv="X-UA-Compatible">
<TITLE>Members</TITLE>
<SCRIPT language=JavaScript>
<!-- Begin
function NewWindowImage(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
//  End -->
</SCRIPT>
<LINK rel="shortcut icon" href="/images/assn60/favicon.ico"><LINK
rel=stylesheet type=text/css href="dynamicstylesheets/globalcss.cfm">
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<SCRIPT type=text/javascript src="global.js"></SCRIPT>

<SCRIPT src="/__utm.js"></SCRIPT>
</HEAD>
<BODY id=nobackground class=miniheader><!-- miniheader ends here --><!-- 186 -->
<DIV style="FONT-FAMILY: arial">
<TABLE width="100%">
  <TBODY>
  <TR>
    <TD align=middle>
      <TABLE border=2 cellSpacing=0 borderColor=#00382b cellPadding=0
      width="100%">
        <TBODY>
        <TR>
          <TD vAlign=top>
            <TABLE id=searchfielddisplay border=0 cellSpacing=0 cellPadding=3
            width="100%">
              <TBODY>
              <TR>
                <TD bgColor=#00382b vAlign=top colSpan=3>
                  <TABLE border=0 cellSpacing=0 cellPadding=0 width="100%">
                    <TBODY>
                    <TR>
                      <TD bgColor=#00382b vAlign=top colSpan=2><STRONG><FONT
                        color=white><FONT size=+0>Sam Abboushi
                        </FONT></STRONG></FONT></TD></TR>
                    <TR>
                      <TD colSpan=2><BR></TD></TR></TBODY></TABLE></TD></TR>
              <TR>
                <TD id=recDetailLbl79 class=recDetailLbl vAlign=top
                  noWrap>Member Number&nbsp;&nbsp;&nbsp; </TD>
                <TD id=recDetailData79 class=recDetailData vAlign=top>5466
              </TD></TR>
              <TR>
                <TD id=recDetailLbl18 class=recDetailLbl>Phone</TD>
                <TD id=recDetailData18 class=recDetailData
                  vAlign=top>281-611-2111 </TD></TR>
              <TR>
                <TD id=recDetailLbl20 class=recDetailLbl>Work Phone</TD>
                <TD id=recDetailData20 class=recDetailData
                  vAlign=top>281-555-5552 </TD></TR>
              <TR>
                <TD id=recDetailLbl72 class=recDetailLbl vAlign=top
                  noWrap>Secondary Member First Name&nbsp;&nbsp;&nbsp; </TD>
                <TD id=recDetailData72 class=recDetailData vAlign=top>Esther
              </TD></TR>
              <TR>
                <TD id=recDetailLbl71 class=recDetailLbl vAlign=top
                  noWrap>Secondary Member Last Name&nbsp;&nbsp;&nbsp; </TD>
                <TD id=recDetailData71 class=recDetailData vAlign=top>Franklin
              </TD></TR>
              <TR>
                <TD id=recDetailLbl75 class=recDetailLbl vAlign=top
                  noWrap>Secondary Member Work Phone&nbsp;&nbsp;&nbsp; </TD>
                <TD id=recDetailData75 class=recDetailData
                  vAlign=top>733-416-3333
      </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV><!-- minifooter starts here -->
<CENTER></CENTER></BODY></HTML>



I would need to parse all the rows to get:
Sam Abboushi
Member Number 5466
Phone 281-611-2111
Work Phone 281-555-5552
Secondary Member First Name Esther
Secondary Member Last Name Franklin
Secondary Member Work Phone 733-416-3333

Note: Records can have more or less rows of data, depending upon the member info collected.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 5:41 am 
Offline

Joined: September 18th, 2004, 5:32 am
Posts: 133
jethrow wrote:
I'm not surprised there are 0 elements with the html tag "data" :wink:


Groan....! :oops: Thanks... I meant "table" He He!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 5:59 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Firstly I'm going to HIGHLY recommend AHKL & COM_L for the object support (though the iWeb functions are written for regular AHK ). Here's an example where your "2) Sample data record" is stored in the variable "html":
Code:
document := COM_CreateObject( "HTMLFIle" )
document.write( html )

table := document.all.tags( "table" )[2]
Loop, % table.rows.length {
   n := A_Index-1
   row := table.rows[ n ]
   Loop, % row.cells.length
      MsgBox, 0, % "Row " . n . " Cell " . A_Index-1, % row.cells[ A_Index-1 ].innerText
}


OR, here is the same thing using regular AHK & COM library:
Code:
COM_Init()
document := COM_CreateObject( "HTMLFIle" )
COM_Invoke( document, "write", html )

table := COM_Invoke( document, "all.tags[table].item[2]" )
Loop, % COM_Invoke( table, "rows.length" ) {
   n := A_Index-1
   row := COM_Invoke( table, "rows", n )
   Loop, % COM_Invoke( row, "cells.length" )
      MsgBox, 0, % "Row " . n . " Cell " . A_Index-1, % COM_Invoke( row, "cells[" A_Index-1 "].innerText" )
}
COM_Release( document ), COM_Release( table ), COM_Release( row ), COM_Term()

You could either get the html & write it to an HTMLFile like this example, or you could simple access the document object from the webpage if you have it open.

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Last edited by jethrow on March 4th, 2010, 8:52 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 6:57 am 
Offline

Joined: September 18th, 2004, 5:32 am
Posts: 133
k Jethrow - I've downloaded AHKL.

Maybe I'm just tired from having been at my desk for about 18 hours straight - but I couldn't find any install instructions. I replaced the autohotkey executable in program files folder and hope that's all I need to do.

Too tired to continue tonight and discouraged too - seems like a completely new direction...

Will try again tomorrow am. To test your script, I assume I assign the html of the webpage to variable 'html' before your script.

Thanks again for your input--

Tank - I am still interested in your response to my earlier questions, particularly regarding the parse table...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 3:19 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
jethrow has demonstrated the exact methods i was going to no need to re post same code

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 4:25 pm 
Offline

Joined: September 18th, 2004, 5:32 am
Posts: 133
Tank - I meant help in how to use
Code:
iWeb_TableParse(pDisp,table,row,cell,frm="")




I'm getting
Quote:
"failed to get a window handle"
and don't know what to try next. Can find no details on this forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 4:27 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
That function is going to change any how and is much less helpfull than what jethrow demonstrated
master the method jethrow demonstrated in normal COM in the previous post

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 5:32 pm 
Offline

Joined: September 18th, 2004, 5:32 am
Posts: 133
k thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 9th, 2010, 1:43 am 
Offline

Joined: April 30th, 2006, 6:23 pm
Posts: 358
Location: Shigle Springs
After being fustrated,, I moved to a blind and stupid way.. (Tank, be nice, and do not make fun of me too much, you know I am stupid!) :lol:

Code:
     pwb   :=   COM_CreateObject("InternetExplorer.Application")
 url = your fricken url
   com_invoke(pwb,"silent") ; silence script errors
   COM_Invoke(pwb , "Visible=", "True") ;"False" ;"True" ;
   nav(pwb,url)
   complete(pwb)
   loop, 6
   {
;iWeb_TableParse(pdsp,table,row,cell,frm="")
uuuuuuuuuuuck := iWeb_TableParse(pwb,"2",a_index,"1")
msgbox, 0, ,%uuuuuuuuuuuck%, 1
}

It takes a little guessing and moving around the a_index & 1,2,3, but it works... :oops:

PS, tank, this resolves my PM questions to ya.. Look, I am a big girl now!

_________________
CPULOCK.com
virusSWAT.com
Computer Repair Computer Service.com
911PCFIX.com


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 29 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: HotkeyStick and 57 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group