Homework question
Posted
#1
(In Topic #980)
Trainee
I'm not interested in being spoon feed but I really need some help!
Thanks
Posted
Guru

Option 1 would be to sign up for an API, that way you could easily get just the data you want. Have a look here
Option 2. As far as I can see, you can read all the page, not part of it. However, once you have the page, you can use Gambas to find the part you want.
Here is some code that will download the whole page of a website and save it in your program's folder. You can then search the file for the text position and grab what you need.
Does that help? No spoon-feeding intended!
Code (gambas)
Posted
Trainee
Posted
Regular

in Main()
sPage = …
Posted
Trainee
Posted
Guru

twbro54l said
It does help! Do you mind if I ask you how can I get the string I want? :
If you mean how to get the correct part out of the saved data then let me know which site you are wanting to use.
Posted
Trainee
Horoscop Berbec 09.05.2016
I can get them in english too, but I will be reading the data based on the date they want. Like for example yesterday, one week ago or one month ago.
Here's what I could get from the source of the page, where the text is located at.
Code
<div class="zodie-content-texts black">
<p>Dimineata promite a fii linistita. Interactioneaza cu cei care iti plac si nu incerca sa iei noi initiative. Ofertele minore se pot dovedi de succes. O serie de sarcini materiale actuale pot fi realizate cu succes la fel de bine.</p>
</div>
Posted
Guru

twbro54l said
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
Please explain exactly what you need better. and what your experience with gambas is.
You say you do not want to be spoon-fed but it also sounds like you are very new to gambas and have no idea where to begin.
If that's the case then don't worry about the spoon-feeding
you will want to use String functions/operators. have you read the wiki?
http://gambaswiki.org/wiki/cat/string
http://gambaswiki.org/wiki/cat/stringop
Code (gambas)
- ' Use the Like keyword to check a string pattern
- Break ' exit the loop as we are finished
If the meta line you're seeking is in the header you may be able to use the Headers array http://gambaswiki.org/wiki/comp/gb.net.curl/httpclient/headers
Edit: forget that i tried and the meta properties cannot be found in the headers
Or you could modify Cogiers method to do it as you read the page. this will be faster as the whole page will not need to be downloaded just the first few lines..
(See the next message)
Posted
Guru

Code (gambas)
Prints…
Un castig financiar ar putea veni ca rezultat al unei miscari pe care nimeni nu se astepta sa o faci. Este posibil ca toata lumea sa fie foarte mandra de tine - si la fel vei fi si tu. Acesta este doa
Posted
Trainee
Ill post updates when I'm done. Thank you guys so much!
Posted
Guru

twbro54l said
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.
Posted
Guru

Here is a good start to your program: -
<IMG src="https://www.cogier.com/gambas/HScope.png">
</IMG>
1 guest and 0 members have just viewed this.


