how to get all text from the webgadget

Just starting out? Need help? Post your questions and find answers here.
ynkrc
User
User
Posts: 55
Joined: Sat Sep 03, 2011 5:28 am

how to get all text from the webgadget

Post by ynkrc »

some webpages content may changed after loading(js control).
so I want to get the final text through the webgadget
but the webgadget getgadgetitemtext method has no #pb_web_alltext parameter.

What should I do?
ynkrc
User
User
Posts: 55
Joined: Sat Sep 03, 2011 5:28 am

Re: how to get all text from the webgadget

Post by ynkrc »

Problem solved, here are some key codes.

Code: Select all

  Protected *OuterHTML, Browser.IWebBrowser2 = GetWindowLongPtr_(GadgetID(WebGadget), #GWL_USERDATA)
  Protected DocumentDispatch.IDispatch, DocElement.IHTMLElement, Document3.IHTMLDocument3
  If Browser
      If Browser\get_Document(@DocumentDispatch) = #S_OK And DocumentDispatch
        If DocumentDispatch\QueryInterface(?IID_IHTMLDocument3, @Document3) = #S_OK And Document3
          If Document3\get_documentElement(@DocElement) = #S_OK And DocElement
            If DocElement\get_outerHTML(@*OuterHTML) = #S_OK;gethtml
            ....or......
            If DocElement\get_innerText(@*innertext) = #S_OK;getalltext
            
You can determine whether the web has been loaded by detecting whether there are some keywords in the text.
I hope it is useful to those who need it.
Last edited by ynkrc on Tue Nov 19, 2024 3:34 pm, edited 1 time in total.
Axolotl
Addict
Addict
Posts: 802
Joined: Wed Dec 31, 2008 3:36 pm

Re: how to get all text from the webgadget

Post by Axolotl »

Thanks, but it looks like this is not executable code.
Regarding the use of GetWindowLong_()
Please see the MSDN note on that.

Note If you are retrieving a pointer or a handle, this function has been superseded by the GetWindowLongPtr function. (Pointers and handles are 32 bits on 32-bit Windows and 64 bits on 64-bit Windows.) To write code that is compatible with both 32-bit and 64-bit versions of Windows, use GetWindowLongPtr.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
ynkrc
User
User
Posts: 55
Joined: Sat Sep 03, 2011 5:28 am

Re: how to get all text from the webgadget

Post by ynkrc »

Thank you for reminding me.
Axolotl wrote: Tue Nov 19, 2024 3:13 pm
Note If you are retrieving a pointer or a handle, this function has been superseded by the GetWindowLongPtr function. (Pointers and handles are 32 bits on 32-bit Windows and 64 bits on 64-bit Windows.) To write code that is compatible with both 32-bit and 64-bit versions of Windows, use GetWindowLongPtr.
Post Reply