Getting links from feeds

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • codejunkie
    New Member
    • Jan 2008
    • 3

    Getting links from feeds

    My last post was not clear I guess, so here I provide and example.

    I'm trying to get links from feeds, for example this article feed:

    Code:
    <script language="javascript" src="http://js.amazines.com/articlefeed.js?c=,68&t=1&b=1&m=5&h=3&r=0&a=&uid=a62ff736-bcd5-48a8-9d2d-2ad50964deb9"></script>
    Any idea what I should do or any resources on this? I've searched extensively for days and found nothing.
  • harshmaul
    Recognized Expert Contributor
    • Jul 2007
    • 490

    #2
    What you need to do is put that script tag you have inbetween a set of <ul></ul> tags. similar to this...

    Code:
    <ul>
    <script language="javascript" src="http://js.amazines.com/articlefeed.js?c=,68&t=1&b=1&m=5&h=3&r=0&a=&uid=a62ff736-bcd5-48a8-9d2d-2ad50964deb9"></script>
    </ul>
    If your trying to scrape the links off the page...

    This works (kinda)...

    Code:
    <?php
    if ($fp = fopen('http://js.amazines.com/articlefeed.js?c=,68&t=1&b=1&m=5&h=3&r=0&a=&uid=a62ff736-bcd5-48a8-9d2d-2ad50964deb9', 'r')) {
       $content = '';
       while ($line = fread($fp, 1024)) {
          $content .= $line;
       }
    
       $content = str_replace("document.write('","",$content);
       $content = str_replace("<li>","",$content);
       $content = str_replace("');","",$content);
       $content = str_replace("	","",$content);
       $content = str_replace("<ul>","",$content);
       $content = str_replace("</ul>","",$content);
    
    	echo $content;
       // do something with the content here
       // ... 
    } else {
       // an error occured when trying to open the specified url 
    }
    ?>

    Comment

    Working...