Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HTM function replacement for IEHTML not matching
#1
OK, you guys answered my SQL query question so quickly it was obviously too simple for you; maybe you can advise me on this issue?

I was using (from prior version of QM) the following to extract data from a web page that lists routing info I place into a database. (I originally created this with the handy QM wizard on the add-in bar that QM comes with).

MSHTML.IHTMLElement el=HtmlFind3("TABLE" "" "[]<TABLE cellSpacing=0 cellPadding=0 width=''100%'' bgColor=#e1e1e1 border=1><TBODY>[]<TR>[]<TD vAlign=top>[]<TABLE cellSpacing=0 cellPadding=2 width=''100%'' border=0>[]<TBODY>[]<TR>[]<TD vAlign=top>[]<TABLE cellSpacing=2 cellPadding=2 border=0>[]<TBODY>[]<TR>[]<TD align=right><FONT face=Arial,Helvetic" win("Nexxon Services - Maxthon Browser") 0 4 0x28)
str thetext=el.innerText

str s = el.innerText

However, the IHTMLElement has been deprecated in favor of the HTM function. But when I try to duplicate the process with HTM(), I can't get a match (although if I add copies of the system functions that apply to the old IHTMLElement to the new version of QM, I can again match using IHTMLElement-but this is obviously not ideal.)


HTM() function as I am using it now:
Htm el=htm("TD" "Part / service #DescriptionSent airbillReturn airbillRMA #Notes[]3DFORCEFX-5200 VIDEO CARD 97493765784 A45422707621 0000725634 " "" win("Nexxon Services - Maxthon Browser" "IEFrame") 0 64 0x21)
str partstext=el.Text

Can anyone advise of any obvious goofs or suggest QM method for identifying this area of HTML so the data can be extracted as IHTMLElement accomplished?


Again, I appreciate your help.
#2
Does not find any elements in that page?
#3
Sorry, I was gone for a few days.

No, I consistently get the error

Error (RT) in Macro44: object not found

I can provide a copy of the page if needed, I can't figure out why it's not working as I am using the wizard, as I described...

As I said, I reintroduced the IHTMLElement into the new version of QM, so I am pulling data ok for the moment, but if you have any suggestions, let me know, please, or if you need more data from me.

Thanks.
#4
Quote:I can provide a copy of the page if needed

Yes.

Is your QM version 2.1.8 or above?
#5
Here is the code I am using to extract data from the web page.


Using the (old) MSHTML.IHTMLElement line, it extracts fine. using the HTM line, errors out with window not found' error.

(As previously mentioned, I copied the old functions pertaining to IHTMLElement into v2.19 to be able to use that function in new version, simply as stopgap measure.)

I created both initially with the wizard bar in QM; Note each has an accompanying 'str s' line; REM out one pair of lines to see the two effects.

I have attached an example of the web page I search on; it remains static except for customer data.

Let me know if you need more info. I am using 2.19 QM (Altho I have tried 2.18 with same effect). Thanks for your input.

Code:
Copy      Help
;;Activate Browser
act "Maxthon"
;Search for appropriate HTML to extract

;BEGIN PROBLEM AREA
;------------------------
;MSHTML.IHTMLElement el=HtmlFind3("TABLE" "" "[]<TABLE cellSpacing=0 cellPadding=0 width=''100%'' bgColor=#e1e1e1 border=1><TBODY>[]<TR>[]<TD vAlign=top>[]<TABLE cellSpacing=0 cellPadding=2 width=''100%'' border=0>[]<TBODY>[]<TR>[]<TD vAlign=top>[]<TABLE cellSpacing=2 cellPadding=2 border=0>[]<TBODY>[]<TR>[]<TD align=right><FONT face=Arial,Helvetic" win("Nexicore Services - Maxthon Browser") 0 4 0x28)
;str s = el.innerText

Htm el=htm("TABLE" "Customer Name:DOLLY SMITH[]Street Address:2220 ABLE ST[]Street Address 2:[]City:BESERKELEY[]State:NB[]Zipcode:44702[]Country:US[]Phone 1:9108754365[] " "[]<TABLE cellSpacing=0 cellPadding=0 width=''100%'' bgColor=#e1e1e1 border=1><TBODY>[]<TR>[]<TD vAlign=top>[]<TABLE cellSpacing=0 cellPadding=2 width=''100%'' border=0>[]<TBODY>[]<TR>[]<TD vAlign=top>[]<TABLE cellSpacing=2 cellPadding=2 border=0>[]<TBODY>[]<TR>[]<TD align=right><FONT face=Arial,Helvetic" win("Nexxon Services - Maxthon Browser" "IEFrame") 0 4 0x28)
str s=el.Text
;------------------------
;END PROBLEM AREA




;;Tokenize & Extract data for DB Input

ARRAY(str) arr = s
;nt = tok(s arr 3 ", ()" 8 arr2)
str CN=arr[0]
CN.findreplace("Customer Name:" "")
str SA
SA.findreplace("Street Address:" "")
str SA2=arr[2]
SA2.findreplace("Street Address 2:" "")
str CY=arr[3]
CY.findreplace("City:" "")
str ST=arr[4]
ST.findreplace("State:" "")
str ZP=arr[5]
ZP.findreplace("Zipcode:" "")
str CT=arr[6]
CT.findreplace("Country:" "")
str PH=arr[7]
PH.findreplace("Phone 1:" "")
str fp=PH
str  PH1 PH2 PH3
PH1.get(fp 0 3)
PH2.get(fp 3 3)
PH3.get(fp 6 4)
PH.from("(" PH1 ") " PH2 "-" PH3)
str SN=arr[8]
SN.findreplace(" Service Notification:" "")
str Service_Co=arr[9]
Service_Co.findreplace("Service Company:" "")
str Service_Co_Short
Service_Co_Short.get(Service_Co 0 1)
str Ticket_No=arr[10]
Ticket_No.findreplace("PO #:" "")
str AS=arr[11]
AS.findreplace("Assigned To:" "")
str PSD=arr[12]
PSD.findreplace("Part Shipped Date:" "")
str Customer_Address
Customer_Address.from(CN "[]" SA " " SA2 "[]" CY ", " ST " " ZP "[]" PH)
str Comments.from("This is a " Service_Co " Warranty Call" "[]" "This Job has not yet been scheduled")
out Ticket_No
out Service_Co
out Customer_Address
out Comments


Attached Files
.zip   Nexxon.zip (Size: 4.04 KB / Downloads: 416)
#6
Since that time, changed not only HtmlFind to htm, but also "Nexxon Services - Maxthon Browser" to "Nexxon Services - Maxthon". Smile

Tip: code will be more clear if you use variables for big strings passed to functions.

Code:
Copy      Help
str st="Customer Name:DOLLY SMITH[]Street Address:2220 ABLE ST[]Street Address 2:[]City:BESERKELEY[]State:NB[]Zipcode:44702[]Country:US[]Phone 1:9108754365[] "
str sh="[]<TABLE cellSpacing=0 cellPadding=0 width=''100%'' bgColor=#e1e1e1 border=1><TBODY>[]<TR>[]<TD vAlign=top>[]<TABLE cellSpacing=0 cellPadding=2 width=''100%'' border=0>[]<TBODY>[]<TR>[]<TD vAlign=top>[]<TABLE cellSpacing=2 cellPadding=2 border=0>[]<TBODY>[]<TR>[]<TD align=right><FONT face=Arial,Helvetic"
Htm el=htm("TABLE" st sh win("Nexxon Services - Maxthon" "IEFrame") 0 4 0x28)

Tip2: use wildcard characters for part of html and/or text that may change or is not useful.
Tip3: don't check Regexp if you don't use regular expression.
Tip4: don't use HTML if the element can be found using text. HTML may change in the future and you will not see it as you would see text change.

Code:
Copy      Help
Htm el=htm("TABLE" "Customer Name:*" "" win("Nexxon Services - Maxthon" "IEFrame") 0 4 0x21)
#7
Hey, thanks, obviously I have a ways to go towards becoming a qm pro. But got it working now.

Last thing, is there any written documentation on the htm coding, i.e. options, etc. I am not sure what could be applied to the command, and can't find anything in detail. Can you post this, or is it TBD?

Thanks
Ryshyn
#8
Only what is in QM Help. Click htm and press F1. If you need info about IHTMLElement and all other interfaces that you can use with html elements, you'll find it in MSDN Library, http://msdn.microsoft.com/library/ .


Forum Jump:


Users browsing this thread: 2 Guest(s)