Homework question

New to Gambas? Post your questions here. No question is too silly or too simple.
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Homework question

Post by BruceSteers »

twbro54l wrote: Friday 27th January 2023 1:29pm Thank you so much! Yes, I'm new to Gambas. I'm going to add the born-date, month and current-date (or the date they want the data for) in a Form and print it in a text area.
Ill post updates when I'm done. Thank you guys so much!
Well welcome to the wonderful world of gambas basic.

Have a good read of the wiki, especially the String pages i gave the links to.
With commands like Instr() and Mid() you can find and extract any data you need.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Homework question

Post by cogier »

This was a bit of fun.

Here is a good start to your program: -

Image
Test-0.0.1.tar.gz
(12.88 KiB) Downloaded 161 times
divineapi632
Posts: 1
Joined: Monday 12th February 2024 6:20am

Re: Homework question

Post by divineapi632 »

Public Sub Form_Open()

Dim hClient As HttpClient 'To create a HTTP Client
Dim sResult As String 'To store the word's meaning

hClient = New HttpClient As "hClient" 'Create a HTTP Client
With hClient 'With the Client..
.URL = "https://divineapi.com/" 'Set up the URL
.Async = False 'No Asynchronous transmission?
.TimeOut = 60 'Don't hang around waiting for more than 60 seconds
.get 'Get the data
End With

While Lof(hClient) ' Lof has a value until all the file has been downloaded

sResult = hClient.ReadLine() ' Read 1 single line

If sResult Like "<meta property=\"og:description\" content=*" Then ' Here the line is found
sResult = Mid(sResult, InStr(sResult, "content=") + 9) ' trim out the left side
sResult = Mid(sResult, 1, RInStr(sResult, "\"") - 1) ' trim out the right side
hClient.Close ' close the stream
Break ' exit the loop
Endif
Wend

Print sResult

End
DigitalDivineapi
Posts: 1
Joined: Wednesday 7th February 2024 8:58am

Re: Homework question

Post by DigitalDivineapi »

twbro54l wrote: Thursday 26th January 2023 4:51pm Im trying to build a horoscope app for school which reads the data from an URL. The question is: How can I read contents of a URL page and get only the data I want? Like the string I want is after "<meta property="og:description" content=xxxxxxxxxxx"" .
I'm not interested in being spoon feed but I really need some help!
Thanks :P
While I can offer you guidance on how to achieve your goal, another option to consider is utilizing the services of Divine API[https://divineapi.com/], which provides robust functionalities for retrieving specific data from URLs, such as extracting the content you're interested in, like horoscope information. Divine API offers easy integration and comprehensive documentation to streamline your development process. It could be a valuable tool for your horoscope app project.
Post Reply