Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Linux Console Weather Client

    Hello everyone.

    I am interested in a Linux Console weather program. I would like to know if a client exists that fetches data from sites such as and allows output to be saved.

    Thanks in advance.

  2. #2
    You could always write a screen scraper in Perl or PHP and add the data to a customised database. In case the HTML has been marked up as a table, perhaps something like the following PHP snippet could work to grab the data:

    PHP Code:
    $t file('');
    for (
    $i 140$i <= 150$i++) print_r($t[$i]); 
    The 140 to 150 are the fictiuous places the temperature is included in. It is illustrative here only.
    You will need a database wrapper to create and execute the INSERT statement and finally a cron job to relieve you of the manual effort in grabbing the data.

    Hope this helps


  3. #3

    So basically line 140 - 150 would be the temperture data, and it basically just prints whatever is between those lines correct?

  4. $spacer_open
  5. #4
    Yes, after the function file() you would in this case pick up the 140th to the 150th element, so that print_r() would produce for instance:
    HTML Code:
    <TD><A HREF="/newscenter/stormwatch/" CLASS="genTitleLink"><B>A few severe thunderstorms central U. S.</B></A></TD>
    If you strip the string above from its html-tags, using the function described here (, you can wrap it in an INSERT statement and execute the statement.

    The above is purely illustrative, you will find that parsing HTML pages using file() produces PHP-arrays with many hundreds of elements and it takes some trying before you obtain the element you are looking for.

    Hope this helps


Posting Permissions

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