Search code examples
wordpressrssfeed

How to create RSS feeds from any webpage that does not have a RSS feed


How to create RSS feeds from any webpage that does not have a RSS feed, I have to create RSS Feed of http://www.espncricinfo.com/rankings/content/page/211271.html and put that on my wordpress website. How I do it?


Solution

  • You can use the below code with PHP CURL and own CSS. This is not the RSS feed but scrap your data as you required.

    <style>.head { display:block; background-color:#FF0000; 
     color:#FFFFFF;}</style>
    <?php
    $curl = 
    curl_init('http://www.espncricinfo.com/rankings/content/page/211271.html');
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
    $page = curl_exec($curl);
    if(curl_errno($curl)) // check for execution errors
    {
    echo 'Scraper error: ' . curl_error($curl);
    exit;
    }
    curl_close($curl);
    $regex = '/<table class="StoryengineTable">(.*?)<\/div>/s';
    if ( preg_match($regex, $page, $list) )
    echo $list[0];
    else 
    print "Not found"; 
    ?>