PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I'm trying to add some content from a remote webpage to my site. I've tried to search for something like this on the forums, but can't really find anything.
Using PHP, how can I simply read some content, for eks. weather info from a remote site (not web service). I have tried out this:
This reads 8192 bytes. How do I know the amount I need to read? I really don't want to read the whole page. Is it at all possible to retrieve just parts of another webside, such as weatherinfo? Or do I have to get access to an xml file containing the info I want?
although I'd use [php_man]file_get_contents[/php_man]() instead of fopen.
As far as getting only part, you still have to read most, if not all of it, because the content could be anywhere on the page. I use [php_man]preg_match[/php_man]() and its cousins to extract information from sites..
sidenote: it's advisable to get the permission of the site you are extracting information from to do so.
If the site is happy for you to extract content, and you are going to be extracting information from the same page each time you may be able to find a piece of the HTML that is constant and acts as a signpost for the content you want.