Solved

Grabbing A Remote URL

Posted on 2000-05-11
7
207 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

732 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