Get data from opened website

Just starting out? Need help? Post your questions and find answers here.
punak
Enthusiast
Enthusiast
Posts: 113
Joined: Tue Sep 07, 2021 12:08 pm

Get data from opened website

Post by punak »

Hi all
I log in to a site and I need the data on the page that is in the labels and text boxes of the site. Is there a way to take a copy of site data through pb?

For example, after entering the customer's username and password on the site and logging in, I need to save a copy of the displayed data such as phone, address, national code, etc. in pb.
I hope my explanation was complete.
dige
Addict
Addict
Posts: 1417
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: Get data from opened website

Post by dige »

I haven't really understood what you want to do yet.

If you want to read dynamic data from the DOM, this is probably only possible via Javascript injection. If you want to read the static html, you can read it with GetgadgetText or use httpRequest()
"Daddy, I'll run faster, then it is not so far..."
DarkDragon
Addict
Addict
Posts: 2347
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: Get data from opened website

Post by DarkDragon »

Using a WebGadget/WebViewGadget or the installed browser outside your application?

If you want to control a browser which is already installed WebDriver is probably the most feasible option.

https://chromedriver.chromium.org/home

https://chromium.googlesource.com/chrom ... _status.md
bye,
Daniel
punak
Enthusiast
Enthusiast
Posts: 113
Joined: Tue Sep 07, 2021 12:08 pm

Re: Get data from opened website

Post by punak »

How can I do this with WebViewGadget?
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Get data from opened website

Post by infratec »

Something like that should work:

Code: Select all

OpenWindow(0, 0, 0, 800, 600, "PureBasic", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
WebGadget(0, 0, 0, 800, 600, "https://www.purebasic.com/french/#loginform")

Repeat
  Event = WaitWindowEvent()
  Select Event
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
          Select EventType()
            Case #PB_EventType_StatusChange
              Debug GetGadgetItemText(0, #PB_Web_HtmlCode)
          EndSelect
      EndSelect
  EndSelect
Until Event = #PB_Event_CloseWindow
punak
Enthusiast
Enthusiast
Posts: 113
Joined: Tue Sep 07, 2021 12:08 pm

Re: Get data from opened website

Post by punak »

Hello, thank you for your useful codes. Is there a function to search values in HTML tags? This is the most important part of the work.
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Get data from opened website

Post by infratec »

Code: Select all

HTML$ = "sjdfhjsf<hello>123</hello>"
Pos1 = FindString(HTML$, "<hello>")
If Pos1
  Pos1 + 7
  Pos2 = FindString(HTML$, "<" , Pos1)
  If Pos2
    Value$ = Mid(HTML$, Pos1, Pos2 - Pos1)
    Debug Value$
  EndIf
EndIf
Last edited by infratec on Sat Apr 13, 2024 9:46 pm, edited 1 time in total.
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Get data from opened website

Post by infratec »

Or with a regular expression:

Code: Select all

.*<hello>(.*)<\/.*

Code: Select all

If CreateRegularExpression(0, ".*<hello>(.*)<\/.*")
  If ExamineRegularExpression(0, "sjdfhjsf<hello>123</hello>")
    While NextRegularExpressionMatch(0)
      Debug RegularExpressionGroup(0, 1)
    Wend
  EndIf
Else
  Debug RegularExpressionError()
EndIf
Post Reply