Page 1 of 1
Get data from opened website
Posted: Fri Apr 12, 2024 11:42 am
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.
Re: Get data from opened website
Posted: Fri Apr 12, 2024 3:38 pm
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()
Re: Get data from opened website
Posted: Fri Apr 12, 2024 3:50 pm
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
Re: Get data from opened website
Posted: Fri Apr 12, 2024 4:47 pm
by punak
How can I do this with WebViewGadget?
Re: Get data from opened website
Posted: Fri Apr 12, 2024 10:42 pm
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
Re: Get data from opened website
Posted: Sat Apr 13, 2024 9:03 pm
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.
Re: Get data from opened website
Posted: Sat Apr 13, 2024 9:34 pm
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
Re: Get data from opened website
Posted: Sat Apr 13, 2024 9:42 pm
by infratec
Or with a regular expression:
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