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
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)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.