Jump to content

Fetch data from webpage.


Grundell

Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/244033-fetch-data-from-webpage/
Share on other sites

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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.