Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How to include data from other ftp site?  (Read 3264 times)

0 Members and 1 Guest are viewing this topic.

sssalvi

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Unknown
    How to include data from other ftp site?
    « on: September 27, 2010, 09:49:32 AM »
    I wish to display a part of numerical data from a ftp site into my website ( phpbb3) http://earth-station-forum.stationforum.com/ .

    How do I do that?

    Enclosing the whole page is easy but how to reproduce only a small data?

    In particular how can I reproduce only the bold text "Solar flux = 83 " form the webpage :http://www.swpc.noaa.gov/ftpdir/latest/wwv.txt

    Quote


    :Product: Geophysical Alert Message wwv.txt
    :Issued: 2010 Sep 21 0906 UTC
    # Prepared by the US Dept. of Commerce, NOAA, Space Weather Prediction Center
    #
    # Geophysical Alert Message
    #
    Solar-terrestrial indices for 20 September follow.
    Solar flux 83 and mid-latitude A-index 2.
    The mid-latitude K-index at 0900 UTC on 21 September was 2 (18 nT).

    No space weather storms were observed for the past 24 hours.

    No space weather storms are expected for the next 24 hours.

    I am not a professional software person ... but have attempted a few complex programs in C BASIC etc.

    Just a very preliminary code will do .. I will try to refine it.

    I tried $string.. $ substr etc but could not succeed.

    Thanks in advance.

    ==========

    S S Salvi

    TristanPerry



      Rookie

      Thanked: 1
      • Yes
      • Computer Lover
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: How to include data from other ftp site?
    « Reply #1 on: September 29, 2010, 04:45:45 AM »
    Are you happy with regex? If so perhaps use curl to fetch the HTML via HTTP, then regex the data out?

    So:

    Code: [Select]
    $connect = curl_init();
        curl_setopt($connect, CURLOPT_URL, 'http://pageurl.com');
        curl_setopt($connect, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($connect, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
        curl_setopt($connect, CURLOPT_POST, TRUE);
        curl_setopt($connect,CURLOPT_CONNECTTIMEOUT,2);
        curl_setopt($connect,CURLOPT_TIMEOUT,2);
        //curl_setopt($connect, CURLOPT_POSTFIELDS, 'Post content. Probably not needed');
        $response_content =  curl_exec($connect);
        $response = curl_getinfo($connect);

    Then use a simple regular expression on $response to get the required data?
    Please feel free to check out my website: Computer Lover

    sssalvi

      Topic Starter


      Newbie

      • Experience: Beginner
      • OS: Unknown
      Re: How to include data from other ftp site?
      « Reply #2 on: September 30, 2010, 04:52:34 AM »
      Thanks TristanPerry,

      Actually HTML, PHP  etc are all equally alien to me.

      Regex is also same.

      So I can just go to basics of it and try to adapt the code for my use.


      Thanks for the input ...  will come back and report the happenings .

      =====
      sssalvi