Solved

Grabbing A Remote URL

Posted on 2000-05-11
7
202 Views
Last Modified: 2006-11-17
I am trying to get the information from http://lumahai.soest.hawaii.edu/cgi-bin/text2.csh?SURFOBS.PHFO,Surf_Observations,Hawaiian_Weather and post it on a local page.

I can get the info fine but I want to display only part of the page. Here are the parts I don't want to show:

- Anything before the actual start of the report.

- And nothing after the end of the report. IE: Not the horizontal rules.

Any ideas?
0
Comment
Question by:phreakin
  • 3
  • 2
  • 2
7 Comments
 
LVL 8

Expert Comment

by:us111
ID: 2800714
Which part would you like ??


FZHW50 PHFO 110000
NSHHFO
SURF OBSERVATIONS AT SELECTED OAHU BEACHES
NATIONAL WEATHER SERVICE HONOLULU HI
2 PM HST WED MAY 10 2000
AFTERNOON  

BEACH             HEIGHTS               REMARKS

EHUKAI             FLAT TO 1              1 PM
SUNSET             FLAT TO 1              1 PM
MAKAPUU            2 TO 4                 1 PM
SANDY BEACH        2 TO 4                 1 PM
DIAMOND HEAD       2 TO 3 OCNL 4          7 AM
WAIKIKI            2 TO 3                 1 PM
ALA MOANA          2 TO 3                 1 PM
NANAKULI           FLAT TO 1              9 AM
MAKAHA             FLAT TO 1              1 PM

SURF ALONG THE SOUTH SHORES WILL BE 1 TO 3 FT TODAY AND WILL
BECOME HIGHER WITH HEIGHTS OF 3 TO 5 FT BY LATE AFTERNOON AND
THURSDAY.

SURF ALONG THE EAST AND WEST SHORES WILL BE 2 TO 3 FT OCNL 4 FT
THROUGH THURSDAY.

SURF ALONG THE NORTH SHORES WILL BE FLAT TO 1 FT THROUGH
THURSDAY.
0
 

Author Comment

by:phreakin
ID: 2800739
SURF OBSERVATIONS AT SELECTED OAHU BEACHES
NATIONAL WEATHER SERVICE HONOLULU HI
2 PM HST WED MAY 10 2000
AFTERNOON    

BEACH             HEIGHTS               REMARKS

EHUKAI             FLAT TO 1              1 PM
SUNSET             FLAT TO 1              1 PM
MAKAPUU            2 TO 4                 1 PM
SANDY BEACH        2 TO 4                 1 PM
DIAMOND HEAD       2 TO 3 OCNL 4          7 AM
WAIKIKI            2 TO 3                 1 PM
ALA MOANA          2 TO 3                 1 PM
NANAKULI           FLAT TO 1              9 AM
MAKAHA             FLAT TO 1              1 PM

SURF ALONG THE SOUTH SHORES WILL BE 1 TO 3 FT TODAY AND WILL
BECOME HIGHER WITH HEIGHTS OF 3 TO 5 FT BY LATE AFTERNOON AND
THURSDAY.

SURF ALONG THE EAST AND WEST SHORES WILL BE 2 TO 3 FT OCNL 4 FT
THROUGH THURSDAY.

SURF ALONG THE NORTH SHORES WILL BE FLAT TO 1 FT THROUGH
THURSDAY.

0
 
LVL 8

Expert Comment

by:us111
ID: 2801742
ok, below is the HTML source of the page.
Is the HTML source always the same ??
I mean
<pre>
FZHW50 PHFO 110000
NSHHFO
blablabla
</pre> ?

And you need blablabla...

Do you already have these 2 lines ??

FZHW50 PHFO 110000
NSHHFO

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:phreakin
ID: 2801761
I would assume those lines change, I just need to get the info from the report. The only really important part to chop off would be the bottom part. I could live with the rest.
0
 

Accepted Solution

by:
Agent_Neo earned 50 total points
ID: 2802250
Here is the script in php to do what you want.

<?php
### Grab URL DATA ###
$url_report = fopen("http://lumahai.soest.hawaii.edu/cgi-bin/text2.csh?SURFOBS.PHFO,Surf_Observations,Hawaiian$

### Parse Report Lines ###
while (!feof($url_report)) {
  $buffer = fgets($url_report, 4096);
  if ($buffer == "<HR>\n") { $found=true; } # Cut off Area
  if ($found == true) {
        Skip;
  }
        else {
                if ($buffer != "<pre>\n" && $buffer != "</pre>\n") { $data .= $buffer;}
  }

}
### Close Report ###
fclose($url_report);

$data = strip_tags($data); # Strip HTML Tags
print $data; # Print Report

?>
0
 

Expert Comment

by:Agent_Neo
ID: 2802258
My Bad. I was copying from Pico (Linux) and din't see I didnt copy all the code:

Where it says:
$url_report

Replace it with this:
$url_report = fopen("http://lumahai.soest.hawaii.edu/cgi-bin/text2.csh?SURFOBS.PHFO,Surf_Observations,Hawaiian_Weather","r");
0
 
LVL 8

Expert Comment

by:us111
ID: 2803446
Less code and only one access to the URL:

<?
$url_report = file("http://lumahai.soest.hawaii.edu/cgi-bin/text2.csh?SURFOBS.PHFO,Surf_Observations,Hawaiian_Weather");

$new_url="";
while (list($index, $value) = each($url_report))
{       $new_url.="<br>".$value;
}

$new_url = split("<pre>", $new_url);
$new_url = split("</pre>", $new_url[1]);
print $new_url[0];
?>
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now