Create RSS Feed From A PHP Page on a Site I Don't Own - Is This Possible?

3 replies
Hi guys,

I'm trying to create an RSS feed of ads from several classified ads sites (that I don't own) that don't currently have an RSS feed on them.

Update: They're not actually all PHP, some are HTML, but so far I haven't had any success with any of the HTML to RSS converters.

Any other ideas or suggestions would be greatly appreciated !

Cheers

Rach
#create #feed #page #php #rss #site
  • Profile picture of the author Jim Westergren
    I am not really sure of the best method but my guess is to parse the URLs with for example CURL and with some regex extract the ads, then input them into a db with a timestamp and then have a script which outputs XML to form a RSS based on the content from your database. Beware that you probably need permission before you can scrape sites and display their content.
    Signature

    Jim Westergren
    JimWestergren.com | TodaysWeb

    {{ DiscussionBoard.errors[3572744].message }}
  • Profile picture of the author Evan-M
    are the sites running on wordpress?

    if so

    <?php
    include_once(ABSPATH . WPINC . '/rss.php');
    wp_rss('http://feedurl.com', 5);
    ?>

    5 is the number of items to display ( you may need to adjust /rss.php to the path relative to where you are running it.


    if not your looking at something more like this

    <?php

    $doc = new DOMDocument();
    $doc->load('http://url.com/feed.xml');
    $arrFeeds = array();
    foreach ($doc->getElementsByTagName('item') as $node) {
    $itemRSS = array (
    'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
    'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
    'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
    'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue
    );
    array_push($arrFeeds, $itemRSS);
    }

    ?>

    then display it with the $arrFeeds array
    Signature

    Evan-M

    Easily The Worlds Best Wordpress Popup plugin

    Visit Website Design Firm For All Your Wordpress Coding Needs

    {{ DiscussionBoard.errors[3573333].message }}
  • Profile picture of the author phpdev
    You have to use CURL for fetching HTML and then use regular expression to extract contents you want.
    Signature
    Ali Usman
    PHP, MySql, WordPress, API Programming, E-Commerce Site, Payment Integration, Twilio, SMS Marketing, Custom Development, Wordpress, Joomla, Interspire, BigCommerce, Volusion, 3dCart and many more...
    sales@bluecomp.net
    {{ DiscussionBoard.errors[3573359].message }}

Trending Topics