开发者

Grabbing football scores from the web in Java

开发者 https://www.devze.com 2023-01-28 13:13 出处:网络
Hey, I am trying to create a program to download football scores and store them. For example, from a site like http://www.flashscores.co.uk/. I would like to be able to leave my program running 24/7 a

Hey, I am trying to create a program to download football scores and store them. For example, from a site like http://www.flashscores.co.uk/. I would like to be able to leave my program running 24/7 and would like it to update as soon as a goal is scored.

Ideally, I would like to use Java. I'm not sure about how to go about doing this. One Idea I had would be to use the jericho HTML parser (http://jericho.htmlparser.net/docs/index.html) to periodically download the page source and search for the required data. Would this work?

Than开发者_JAVA技巧ks


The site you provided gets it's scores from LIVESCORE.in, they allow you to have the same type of display shown on flashscores.co.uk and you can customize it. There will be ads and they restrict your usage. But you can customize it, so if you just want to display scores on your site, that's the way to go.

However, if you are wanting to scrape the scores in order to use them, that is a violation of their terms (see link above). You could always contact the company they are using, Xscores.com and pay them.


Ever wonder why prices on some sites don't show up until you add to cart? Now you know; as others have said understand the Terms of Service of any site you want to pull data from. That's really why many sites have those sorts of policies is preventing people from screen scraping.

So to answer your question from a technical perspective, with Java, you probably want to set this up as a Daemon thread - that is a process that can run in the background repeatedly. This would probably make periodic HTTP requests to some API (or screen scrape). What's important is to understand the API or as you suggest use an HTML parsing library. If you end up going the latter route, I encourage the use of one that can produce an XML document so you can execute xpath queries against it to get the data you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消