Jump to content

Fetch data from another website


nlandstrom

Recommended Posts

Hi,

 

I am quite new to PHP and to learn more about it I decided I would make a little project to easy my life a little bit :)

 

I want to make a site that fetches lunch menus from the restaurants nearby my work. I would just like some help getting pointed in the right direction on how to make this happen :)

 

Thanks!

 

Br,

Niklas

Link to comment
Share on other sites

So you want to take their content, store it yourself to display.

 

Most websites frown on this and consider it theft, while others may allow you to do this.

 

It's best to ask their permission before starting this.

 

But if you do have permission....

Need a way to connect to the site and obtain some data so look into:

dom, simplhtmldom, curl, file_get_contents(), simplexml

 

Some of the ways above can get specific data from tags on a page, others must find the content using regex, with preg_match(), preg_match_all()

 

Once you have the desired content, is best to filter and escape bad characters, you may run into different character encoding

 

Then you insert the data into mysql in whatever database design you came up with,  then fetch/select the data you want to display.

http://www.php.net/manual/en/ref.mysql.php

Link to comment
Share on other sites

I have to say this seems like the kind of project that would be way more trouble than it is worth. Each restaurant will have their menu in a very different format, and you only use each format one time. It would be easier to just grab the page and save it on your computer maybe as a PDF or .html, rather than writing the code to scrape each page and save it in a DB. What do you plan to do with the data once you have it that makes this worth while?

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.