Grundell Posted August 6, 2011 Share Posted August 6, 2011 Hello, I'm new here so I hope that this isn't a repeat of a previous question. So what I'm doing is a page where i need to fetch the data from or rather i need to get the text within a certain <div> from another webpage (It's a project where i try to gather the daily menu from different restaurants on one single page). The problem is that some of them doesn't have RSS -Feed and so on, so what i need to to is create a script where i actually fetch the data from the actual file on another server that i don't control. So i wondered if any knows, maybe even has a script that would fit in?, how to walk around the problem or if it's a dead end because of different web-kits? Thanks beforehand. Grundell Quote Link to comment https://forums.phpfreaks.com/topic/244033-fetch-data-from-webpage/ Share on other sites More sharing options...
phpSensei Posted August 6, 2011 Share Posted August 6, 2011 http://simplehtmldom.sourceforge.net/ Its simple, you call the file_get_html function which will return the contents of the url page you require, then use the built in the functions to get the elements you require. The other option is file_get_contents and use a preg_match regex pattern to grab the div's content. see here preg_match('/<div(.*?)>(.*?)<\/div>/is', $content, $matches) Quote Link to comment https://forums.phpfreaks.com/topic/244033-fetch-data-from-webpage/#findComment-1253223 Share on other sites More sharing options...
TeNDoLLA Posted August 6, 2011 Share Posted August 6, 2011 Or 3rd option is to grab the data with file_get_contents() and use the DOMDocument of PHP. http://php.net/manual/en/class.domdocument.php Quote Link to comment https://forums.phpfreaks.com/topic/244033-fetch-data-from-webpage/#findComment-1253232 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.