Alex Rivera | Logout

Fetch HTML page and store it in MYSQL- How to

Asked 2010-05-03T21:04:36.683
14
  • What's the best way to store a formatted html page with CSS on to MYSQL database? Is it possible?
  • What the column type should be? How to retrieve the stored formatted HTML and display it correctly using PHP?

  • What if the page I would like to fetch has pics and videos, show I store the page as blob

  • What's the best way to fetch a page using PHP-CURL,fopen,..-?

Many questions guys but I really need your help to put me on the right way to do it.

Thanks a lot.

Edit
Report

1 Answer

1

Pull down the whole page using fopen and parse out any URLs (like images and css). You'll want to run a loop to grab each of the urls for files that generate the page. Store these as well, and replace the urls that used to link to the other sites files with your new links. (this will avoid any issues if the files should change or be removed in the future).

I'd recomend using a blob datatype just because it would allow you store all the files in one table, but you could do a table for the pages with a text datatype and another with blob to store images and other files.

Edit: If you are storing as a blob datatype look into base64_encode() it will increase the storage footprint on the server but you'll avoid any issues with quotes and special characters.

answered 2010-05-03T21:57:27.330

Your Answer