Horatiu Jeflea
Horatiu Jeflea

Reputation: 7404

How can I save content from another website to my database?

I want to upload dynamically content from a soccer live score website to my database.

I also want to do this daily, from a single page on that website (the soccer matches for that day).

If you can help me only with the connection and retrieval of data from that webpage, I will manage the rest.

website: http://soccerstand.com/ language: php/java - mysql

Thank you !

Upvotes: 0

Views: 3735

Answers (3)

ilhan
ilhan

Reputation: 8961

Using curl you will get the content of the page, then using regex you will get what you want.

There is an easy way: http://www.jonasjohn.de/lab/htmlsql.htm

Upvotes: 1

Mike
Mike

Reputation: 611

Ethical questions about scraping other site's data aside:

With php you can do an "open" call on a website as long as you're setup corectly. See this page for more details on that and examples: http://www.php.net/manual/en/wrappers.http.php

From there you have the content of the web page and it's a matter of breaking it up. Off the top of my head, I'd use regular expressions or an HTML parser to break apart the HTML, and then loop through the child elements and parse the data into your database calls to save the data.

There are a lot of resources for parsing HTML on the web and it's simply a matter of choosing the one that will work best for you.

Keep in mind you'll need to monitor the site for changes, because if they change elements, or their classes/ids you might need to change your parsing structure as well.

Upvotes: 1

echo
echo

Reputation: 7855

You can use php's file function to get the data. You just pass it a URL and it returns the content as an array of lines from the file. You can also use file_get_contents to get the content as one big string.

Upvotes: 1

Related Questions