How to copy data from Weather websites?

Discussion in 'HTML & Website Design' started by MiletNZ, Sep 17, 2010.

  1. #1
    I'm looking at having some weather and ocean conditions on my site, updating regularly from the local weather site. Can anyone give me some sort of idea how to do this?

    The sort of data I'm talkin about is this

    http://www.weathermap.co.nz/boating/kaikoura-peninsula
     
    MiletNZ, Sep 17, 2010 IP
  2. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #2
    Last edited: Sep 18, 2010
    Kerosene, Sep 18, 2010 IP
  3. MiletNZ

    MiletNZ Member

    Messages:
    283
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #3
    Thanks for that, I am a big NOOB and only have basic to intermediate HTML skills so will have a good read over this. Thanks!
     
    MiletNZ, Sep 18, 2010 IP
  4. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #4
    Here's something to get your started. Save it as whatever.php, then put it on your website. (You'll need CURL and PHP5)

    <?php
    function My_simplexml_load_file($URL)
    {
    $ch = curl_init($URL);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $xml = simplexml_load_string(curl_exec($ch));
    curl_close($ch);
    return $xml;
    }
    ?>
    
    <?php
    $url='http://www.weathermap.co.nz/feed/boating/kaikoura-peninsula';
    $xml = My_simplexml_load_file($url);
    if ($xml!=''){
    foreach ($xml->channel->item as $item){
    $description = $item->description;
    echo $description;
    }
    }
    ?>
    PHP:
    Keep in mind that there's a certain etiquette to pinching peoples feeds.
    It's probably a good idea to either ask first, or at least give the source a good back link.
    :)
     
    Kerosene, Sep 18, 2010 IP
    JJulian likes this.
  5. MiletNZ

    MiletNZ Member

    Messages:
    283
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #5
    Thanks so much!
     
    MiletNZ, Sep 18, 2010 IP
  6. MiletNZ

    MiletNZ Member

    Messages:
    283
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #6
    You're a Legend. I've got the data on there, now I just need to fiddle around with the format of it somehow. I will also double check with this site that it is okay to do this and give them backlinks - I don't see it as a big problem as I've seen other sites using the data and referencing them as the owners.

    I'm always learning from this site thanks to people like you.
     
    MiletNZ, Sep 18, 2010 IP
  7. MiletNZ

    MiletNZ Member

    Messages:
    283
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #7
    Sorry.. Any Idea how to display it as it is on the link above?
     
    MiletNZ, Sep 19, 2010 IP
  8. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #8
    You won't be able to get it to display the same as the website - at least not without a lot of stuffing around with PHP.
     
    Kerosene, Sep 19, 2010 IP
  9. MiletNZ

    MiletNZ Member

    Messages:
    283
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #9
    No problem, thanks again. Will just leave it as it is.
     
    MiletNZ, Sep 19, 2010 IP
  10. suraja

    suraja Peon

    Messages:
    537
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Bookmarked, such pretty code
     
    suraja, Sep 19, 2010 IP
  11. zzbomb

    zzbomb Peon

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
  12. MiletNZ

    MiletNZ Member

    Messages:
    283
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #12
    MiletNZ, Sep 21, 2010 IP
  13. MiletNZ

    MiletNZ Member

    Messages:
    283
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #13
    I emailed that site, they had no problem with me posting their feeds on my site. He also said

    Whats the difference between RSS posts and APIs?
     
    MiletNZ, Sep 23, 2010 IP