Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GetHtmlElements: 2 pop-ups appearing, taking focus away from firefox
#1
I fetch HTML using

Macro Macro100
Code:
Copy      Help
str html_string
int w=wait(3 WV win("Mozilla Firefox" "MozillaWindowClass"))
Acc a.Find(w "DOCUMENT" "" "" 0x3010 3)
a.WebPageProp(0 0 html_string)

HtmlDoc d.InitFromText(html_string)
ARRAY(MSHTML.IHTMLElement) divblock
d.GetHtmlElements(divblock "div") ;; <===== SOME CODE/CLASS/FUNCTION WITHIN "GetHtmlElements" TRIGGERS POP-UP (SEE BELOW FOR POP UP)

Something within ".GetHtmlElements"  causes 2 popups to appear which causes focus being taken away from firefox.
I can get the window information from the small "Windows Security Warning" pop-up so I can use it in 'win' command.
But I can not fetch info from the other popup "You'll need a new app..." as soon as you press a key it dissapears.

I have used the following command to get all window class/name/id but still couldn't fetch the info of the "You'll need a new app..." popup:
command used: win("" "" "" 0 0 0 a) then attempted to move mouse to the each of the windows stored in "a", but the mouse did not move to the "You'll need a new app..." popup, but other windows strored in "a" did work.

QUESTION: Is there something I could do to avoid the 2 pop-ups from showing up?

I can [ESC] both windows (no need to place cookie) and my code still works.
It's just very annoying that those 2 pop-ups appear, sometimes (in the past) only the small "Windows Security Warning" only appeared.

Even if I had a way to target the "You'll need a new app..." popup it is still all happening within  "GetHtmlElements" so I need to wait until "GetHtmlElements" is finished and then after that do an if "w" exists ("w" beeing the "You'll need a new app..." popup) but this is not possible because
something within "GetHtmlElements" is keeping from completing it's process. I think I need to launch a seperate process before "GetHtmlElements"  which checks for the existance of the popups and then closes them. But I was hoping for another more effective solution. (if possible).


The 2 pop-ups:

The first one, appears last = becomes active window (top of stack)
   

This one appears directly below the above one
   
#2
To close the popup use other thread. Start it with mac, like mac "sub.MySubfunction", before the code line that triggers the popup.

-----

Or use FFNode instead of IHTMLElement.

Macro Macro533
Code:
Copy      Help
int w=wait(3 WV win("Mozilla Firefox" "MozillaWindowClass"))
FFNode doc.FromDoc(w)
doc.FindFF(doc "div" "" "" 0 0 0 &sub.Callback_FindFF)


#sub Callback_FindFF
function# FFNode&x level cbParam FFNODEINFO&ni

;Template Callback_Acc_Find contains more info about this callback function.

;From x you can get html element tag, HTML, text, attributes, siblings/children/parent, some other info. Also to convert to Acc if possible.

out "-----"

out x.HTML

;ARRAY(str) a
;x.AttributesAll(a 1)
;out a

;Acc k.FromFFNode(x 1)
;k.Role(_s); out _s
;k.Location(...

ret 1

-------
#3
Thank you!!!
#4
Sorry one more question.

Using your example I was able to extract all divs which have a classname that begins with "row\s" (regx, 'row' followed by a space).

Macro Macro101
Code:
Copy      Help
int w=wait(3 WV win("Mozilla Firefox" "MozillaWindowClass"))
FFNode doc.FromDoc(w)
doc.FindFF(doc "div" "" "class=^row\s" 8 0 0 &sub.Callback_FindFF)

Then in the subfunction I used

Macro Macro101
Code:
Copy      Help
Acc k.FromFFNode(x 1)
str tag innerHTML outerHTML
k.WebProp(tag innerHTML outerHTML)


It results in multiple HTML blocks beeing extracted:

 
Code:
Copy      Help
<DIV class=icn>
    <A class=fulllink href="https://www.TEST.com/" target=_blank>
    <IMG src="https://thumb.png"> <================================================= get  'https://thumb.png'
    </A>
</DIV>
<DIV class=gameinfo>
    <DIV class=title>
        <A href="https://TEST.com/" target=_blank>some title</A> <================================================= get   'some title'  (inner text)
        <DIV class=js-subproduct-admin-edit data-machine-name="qm_studio" data-entity-kind="subproduct"></DIV>
    </DIV>
    <DIV class=subtitle>
        <A href="https://www.syntystudios.com/" target=_blank>QM Studios</A>
    </DIV>
</DIV>


QUESTION:

1)
What is the best method to extract:
https://thumb.png
FROM:  div class = "icn"
EXTRACT: IMG src
(I marked it above in the code with arrow:   <==============   )

2)
What is the best method to extract:
some title
FROM:  div class = "title" ,
EXTRACT: the innertext from the   <A href'   which is  within   div class = "title"
(I marked it above in the code with arrow:   <==============   )

What I would attempt to use is

Macro Macro101
Code:
Copy      Help
int i
HtmlDoc d.InitFromText(outerHTML)
ARRAY(MSHTML.IHTMLElement) extract_el_arr
d.GetHtmlElements(extract_el_arr "A" "")
for i 0 extract_el_arr.len
,_s=extract_el_arr[i].className
,if(_s=....)
,,....


But I do not know what best approach / proper approach is.
Maybe I am using incorrect / cpu resource waisting method (?)


Forum Jump:


Users browsing this thread: 1 Guest(s)