Results 1 to 6 of 6
  1. #1

    Help with news feeds from Yahoo!

    Ok,
    I worked on this earlier in the summer and haven't touched it since July so the coding no longer works with Yahoo's current coding. Is there anyway I can code this so that it works even if Yahoo changes their coding format on their news pages?

    Here is an example page, you will notice that it does not stop displaying the page correctly. It did however display the page correctly in July and August.
    http://news.findxp.com/story.php?tmp...ance_floods_27

    And here is my coding for story.php:
    <php
    $fp = fsockopen ("story.news.yahoo.com", 80, $errno, $errstr, 30);
    if (!$fp) {
    echo "$errstr ($errno)<br>\n";
    } else {
    fputs ($fp, "GET /news?tmpl=story&u=" .$_GET[u]." HTTP/1.0\r\nHost: www.yahoo.com\r\n\r\n");
    while (!feof($fp)) {
    $output = $output.fgets ($fp, 256);
    }
    fclose ($fp);
    $news_begin = strpos($output, "<!-- TextStart -->");
    $news_end = strpos($output, "<p>", strpos($output, "<!-- TextEnd -->"));
    $news_pos = (strpos($output, "<p>", strpos($output, "<!-- TextEnd -->")) - strpos($output, "<!-- TextStart -->"));
    $news = substr($output, $news_begin, $news_pos);
    $news = str_replace("eeeeee", "9E0B0B", $news);
    $news = str_replace("dcdcdc", "ECC630", $news);
    echo $news;
    }
    ?>

    BTW, I am fairly new at PHP programming, so any sort of explaining to your solution would be greatly appreciated. Thanks. Also on a side note, I do plan on attaching to all pages where the data came from. Thanks.

  2. #2
    Join Date
    May 2002
    Location
    UK
    Posts
    2,994
    I would guess that Yahoo have simply changed the format of their news stories... apart from that and the fact you are probably not supposed to resyndicate their news... but that's a different matter

  3. #3
    I know, I know.
    Domain Software, LLC.

  4. #4
    Join Date
    May 2002
    Location
    UK
    Posts
    2,994
    My starting point would be comparing the HTML from an old news story and compare it with a new one and see what's changed

  5. #5
    I know, but I was wondering if there was some way I could code it so that it didn't matter if the coding on the page started? Because my current process is basically static, so I was wondering if there was a dynamic way of doing it? Thanks.
    Domain Software, LLC.

  6. #6
    Join Date
    May 2002
    Location
    UK
    Posts
    2,994
    Not really. I suppose you could make guesses but without some form of structure to the data you wouldn't be able to tell the difference between the title and body. This is what XML was invented for.

Related Posts from theWHIR.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •