View Full Version : Using PHP to get data from feed

01-24-2008, 05:22 AM
This one is tough.

I need to get the data from a feed that is embedded like this:

<script src="http://example.com/0809897.js"></script>

I don't even know where to start, can somebody help me please?

01-24-2008, 05:26 AM
Maybe cURL or MagpieRSS (http://magpierss.sourceforge.net/) is what your looking for.

Here is a simply tutorial on link/content scraping using cURL. Myself, I've barely touched cURL, but I'm pretty sure it can do what you need.

01-24-2008, 05:35 AM
So is this some kind of ajax stuff? then it might not be easy to scrape that with something like curl, if you have a larger example it might be easier to help you.

01-24-2008, 06:04 AM
Skyrider, for example this article feed:

<script language="javascript" src="http://js.amazines.com/articlefeed.js?c=,68&t=1&b=1&m=5&h=3&r=0&a=&uid=a62ff736-bcd5-48a8-9d2d-2ad50964deb9"></script>

01-24-2008, 07:56 PM
The Javascript won't execute server side so using CUrl won't help. That is unless you dig into the script a little further and find out where and how it's getting the raw data in the first place. If that data is accessible, then you can pull it that way.

Keep in mind however, information like that isn't necessarily free. If the information provided by that script took money and resources to compile, the company or individual that wrote the script, may not appreciate your circumvention of all their efforts to at least identify themselves as the provider. If they compiled the data and are serving it up, they own it.

If they discover that you are pulling the data in a way they would prefer you not, they can cut you off. If they have an API/developer key/registration process or can provide the means and permission to access the data differently, that's a much better route.