Jump to content

get content of each .HTML files & put it in database


anarchoi

Recommended Posts

Hello,

 

I have a old site that is 100% plain html files. I'm looking to migrate the site to work with a php-built CMS. The problem is that i have thousands of articles in html format, and I don't want to add them all one-by-one through the admin section of my CMS. So the only solution for me is to find a code that would take the html codes inside each of my static html files, and create an entry in my database with the content found.

 

My site's structure is currently like this:

 

www.mysite.com/books/Name Of The Book.html

 

 

I have chosen JOOMLA for my CMS. Joomla stores its articles in a table called "jos_content"

 

the structure of "jos_content" for the imporant article infos is:

"id" = ID of the article, so we have to increase this by one for each new article

"title" = Title of the article. In my case i'd put here the filename of the .HTML since it is the title of my articles

"introtext" = text of the article. It should be the content inside of my HTML files

 

So basically i'd need a code that would look for these informations and create a new entry for each of the .HTML files found in my /books/ server. For the rest I can do it myself, but if someone can hook me up with a code that would do what I explained above it would greatly help me to have somewhere to start since i'm still a newbie with php!

Link to comment
Share on other sites

I think you might have a problem in that you're going to have to give the script a list of all the urls. However saying that, I suppose it's only a large array of strings.

 

Do your articles have a standard html format? i.e. body->div->h1->div->p

You could use a regular expression to parse the html itself and grab the relevant html tags and their content before inserting into a database. (This is after you do a fopen/fread to get the file first ;))

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.