Link to home
Start Free TrialLog in
Avatar of Jerry L
Jerry LFlag for United States of America

asked on

PHP or Perl: Content Generation Script Needed

------------------------------
              Intro
------------------------------
I need to find an existing PHP or Perl script, or have one custom written.

------------------------------
      Project Description
------------------------------
I have over 500 articles that I need to post to my website but I don't want to post them all at once.  I want post a few and then add a few more every day until they are all posted.

I have a rotate.php script that generates the pages, on the fly, and displays the current article, and then the complete list of all the other articles below it.  You click on a link to read another article, the page of which is generated by rotate.php, and so on.  

The current script, rotate.php, refers to a text file, auto.txt, which has all 500 article titles and short descriptions listed.  

But since I don't want to start with all the articles listed, I need to create a script that determines what articles are available for posting, and creates a new auto.txt on the fly with just those articles.  Then in a day or two, I would have to run the script again, but include a few more of the articles.  

------------------------------
    Generating Auto.txt
------------------------------
You can see the contents of auto.txt that need to be generated (see source file below).  The short description must be extracted from the article itself, which is a php file.  For example, the title of the article is: 10_health_fitness_tips.php.  This title appears three times in the file, once in the <title> tag, once in the <meta description> tag, and finally, above the text of the article itself.  

A fixed number of words are included in the auto.txt description, followed by an elipsis (...).  You can see an example of the article and the auto.txt, below.

Sometimes, the title of the article itself includes a dash in the file name, and it never includes the underscores, so matching the text string may be a little tricky.

------------------------------
      PHP or Perl Script
------------------------------
I'm not sure if a PHP script can run on my hard drive.  I could place the new articles in a folder for it to read.  Or does it have to be on the server?  I don't want the articles on the site where the search spiders would find it.  Don't know if they will ignore it using robots.txt.  Or, could the script read the articles from another site of mine where it would be a repostitory of articles there?  

Or, it could be a Perl script to run on my hard drive to generate the auto.txt file.

--------------------------------
       Source: auto.txt
--------------------------------
<font size="2" face="Arial" color="#0000FF">
<b><a href='
10_health_fitness_tips.php'>
10 Health Fitness Tips</a></b></font><BR>

More than any other time in history, people are all trying to have the best, healthiest body possible. The health and fitness industries are making billions of dollars every year on herbal supplements, fitness equipment, gyms, and special diets. If...<br>
<hr color="#C0C0C0" size="1" style="width: 100%">

#BREAK#
<font size="2" face="Arial" color="#0000FF">
<b><a href='
15_minutes_to_firm_arms_bye_bye_jiggle_arms.php'>
15 MINUTES TO FIRM ARMS - Bye bye Jiggle Arms</a></b></font><BR>

Are you hiding your arms because they are flabby and have that jiggle effect when waving to a friend? Good news! No more jiggle arms, or as many call them "grandma arms"! We will be doing some toning exercises to have sexy arms and wave proudly...<br>
<hr color="#C0C0C0" size="1" style="width: 100%">

#BREAK#

--------------------------------------------------
       Source: 10_health_fitness_tips.php
--------------------------------------------------
<title>10 Health Fitness Tips</title>
<meta http-equiv="DESCRIPTION" content="10 Health Fitness Tips">
           . . .
                  <td><b>10 Health Fitness Tips</b><br><br>
                         More than any other time in history, people are all trying to have the best, healthiest body possible. The health and fitness industries are making billions of dollars every year on herbal supplements, fitness equipment, gyms, and special diets. If you watch TV or read magazines, there is always some intriguing commercial asking for money to help you get into shape. <br><br>
           . . .
Avatar of ClickCentric
ClickCentric

The easiest way to do this would be to simply put the auto.txt file on the server and split it into 2 files. In the first file, have the ones you want currently posted and the rest in the second file.  Then just update the first file on the server every couple of days with the article sections that you want to add.  Based on what you've described, a custom script would definitely be needed to do what you're asking.
Avatar of Jerry L

ASKER

Does anyone here have something close to what I need?  It'll give me something to start with.


It is extremely unlikely that someone has a script that will do anything very close to what you want, without your having to modify the architecture of the auto.txt file, and the code in the rotate.php file.

If I were you, I would edit the code in the rotate.php file as follows:

1) Hardcode the date you want this to start, perhaps as a unix timestamp - you might call this STARTDATE

2) Hardcode that rotate.php show only the first 100 articles, you might call this NUMBER_OF_ARTICLES

3) If the CURRENT date is more than ONE DAY greater than STARTDATE, increase NUMBER_OF_ARTICLES by the number of articles you want to add each day.

4) Change the code in rotate.php that reads the articles from auto.txt to limit the number of articles to the new value of NUMBER_OF_ARTICLES.

If you post the contents of rotate.php, I might write this for you.
I dont quite get the logic if this script.

first you got this kind of "menu / description" in the auto.txt of wich the content is in "content_name.php" all generated by the "rotate.php" ?

what should the "outcome" look like, can you supply an example of some site?

regards, May
ASKER CERTIFIED SOLUTION
Avatar of ClickCentric
ClickCentric

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jerry L

ASKER

That sounds like a great alternate solution, ClickCentric.  Can you recommend any such code samples, or what sites to look at?

I think you are correct about the scraping, and yes, it is my own site content.  

I already have the rotator.php, which refers to the auto.txt.  Therefore, I'd like to complete this project before going on to the RSS solution.  Any help with creating the auto.txt would be appreciated.
Well, I need some details about the site you're scraping from to help with that.  How are the articles stored on the content site?  In a database?  Flat files?  Hard coded into individual php files (this would be unusual, but not the first time I would have seen it).  Or do you want something that would just go to the page and pick the information off of the page and modify it to the format that you need?  If it's the latter, I'd need to see the page you're scraping from before I could offer a suggestion.