Jump to content

How to check a website once a day for winning numbers.

_Omega_

Hey i have a few tickets for a Christmas charity lottery were they once a day announce the winning numbers on their website. 

Its really not to hard to check once a day if i have a winning ticket, but i thought it might be a fun programming task to learn something new. 

 

I have some experience in Java and MATLAB (but both more for data processing (results of experiments/simulations)) + some knowledge in C for programming Arduinos.

 

Now to my question:

Is it a reasonable task i could handle? 

 

And if yes, can someone give me some sort of starting point or link to some tutorial? 

 

 

thanks in advance 🙂

 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Neither of those languages are all that great for easily doing stuff like this. Python is probably easier to work with and the amount of third-party libraries for doing web stuff is great.

My advice would be to check if the website offers an API for you to use that would allow you to pull the information easily. Otherwise something like Selenium Webdriver or Requests are both good python libraries for navigating the web and scraping info off web pages.

AMD Ryzen R7 1700 (3.8ghz) w/ NH-D14, EVGA RTX 2080 XC (stock), 4*4GB DDR4 3000MT/s RAM, Gigabyte AB350-Gaming-3 MB, CX750M PSU, 1.5TB SDD + 7TB HDD, Phanteks enthoo pro case

Link to comment
Share on other sites

Link to post
Share on other sites

Definitely! One of my first big projects was creating a web scraper in Python, and it's a great project to learn more about web tech. 

There's two options usually:

- Simulate the browser

- Make the requests programmatically and parse the html. 

 

Now, i'm not too familiar on scraping tools for Java or C. There may also be caveats with the page you're trying to access - like it being JavaScript generated which you'll need to parse if you're making the requests yourself. Though as a starting point you can try firing a get request, parsing the body, and extracting the numbers. I've a had a quick look at what's available for Java since that's probably the quickest to develop this in:

 

 

Jsoup looks very promising, it seems to wrap the HTTP calls and the parsing. I'd say that's a good shout.

 

When it comes to scraping, you'll need to programmatically locate the element that has the data you're looking for. You need to find a "pattern" of where the data is that you want to extract. In HTML there's attributes like name, id, class etc. that you parse out to get the data you need. Jsoup should have plenty of documentation on how to do that. 

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, Coaxialgamer said:

Neither of those languages are all that great for easily doing stuff like this. Python is probably easier to work with and the amount of third-party libraries for doing web stuff is great.

Eh?

 

29 minutes ago, _Omega_ said:

I have some experience in Java

Jsoup, here is an example:
https://www.baeldung.com/java-with-jsoup

VGhlIHF1aWV0ZXIgeW91IGJlY29tZSwgdGhlIG1vcmUgeW91IGFyZSBhYmxlIHRvIGhlYXIu

^ not a crypto wallet

Link to comment
Share on other sites

Link to post
Share on other sites

8 minutes ago, Biohazard777 said:

Eh?

Missed Java on my original read-through, which is a reasonable option. I don't think anyone would try to argue that C or MATLAB are all that web-focused though.

AMD Ryzen R7 1700 (3.8ghz) w/ NH-D14, EVGA RTX 2080 XC (stock), 4*4GB DDR4 3000MT/s RAM, Gigabyte AB350-Gaming-3 MB, CX750M PSU, 1.5TB SDD + 7TB HDD, Phanteks enthoo pro case

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, Coaxialgamer said:

Missed Java on my original read-through, which is a reasonable option. I don't think anyone would try to argue that C or MATLAB are all that web-focused though.

Heh, I agree though if OP is very familiar with MATLAB he could theoretically use urlfilter 😀. Which is definitely not something you and I would use heh, but hey if that is something he is comfortable with, why not 😄 (same goes for C).

VGhlIHF1aWV0ZXIgeW91IGJlY29tZSwgdGhlIG1vcmUgeW91IGFyZSBhYmxlIHRvIGhlYXIu

^ not a crypto wallet

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Biohazard777 said:

Heh, I agree though if OP is very familiar with MATLAB he could theoretically use urlfilter 😀. Which is definitely not something you and I would use heh, but hey if that is something he is comfortable with, why not 😄 (same goes for C).

Im not 😄 i can do complex math tasks and simulations in simulink for chemical engineering.  So i dont have much on an idea of web stuff, but thats more or less the reason i want to do it 😄

 

Link to comment
Share on other sites

Link to post
Share on other sites

Thank you guys for all you input, its getting a bit late for me to really get into it, but at least i know that its a reasonable task and it would even be possible in Java. But i might look into Python as well 

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Vicarian said:

C# is similar to Java syntax-wise, and has a built-in class in .NET for working with Web requests without needing a third-party library (open source or otherwise). 

Java has HttpClient built in... It is just as "simple" to use as .NET WebRequest for what OP wants to do. 
By "simple", he would need to manually extract the info he is looking from a potentially lengthy String (instead of using selectors to find elements like a sane person 😀). Which is why I didn't recommend it in the 1st place....

I do agree about the API remark, if it is available that is the way to go.

VGhlIHF1aWV0ZXIgeW91IGJlY29tZSwgdGhlIG1vcmUgeW91IGFyZSBhYmxlIHRvIGhlYXIu

^ not a crypto wallet

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×