Solved

Grabbing A Remote URL

Posted on 2000-05-11
7
201 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

708 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

17 Experts available now in Live!

Get 1:1 Help Now