473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How to grab a piece of text with help of a php-script

Hi group, I would like to show the latest aurora data on my site.
I know this is possible with help of a php-script, but I'm a nitwit with
php-scripting.
That's why I'm asking for help here.

The following url is being updated once every minute.
http://sec.noaa.gov/ftpdir/lists/ace/ace_mag_1m.txt
and contains data for the past 2 hours.

I would like to show the most recent Bx, By, Bz en Bt values (see line 21)
as following:.
Bx=x.x By=x.x Bz=x.x Bt=x.x (where x.x is the most recent value)

Does anyone know how I can do this with a small script?
Help is highly appreciated !!

Thanks in advance...

--------------------------------------------------------------------------------
Mijn Postvak In wordt beschermd door SPAMfighter
14181 spam-mails zijn er tot op heden geblokkeerd.
Download de gratis SPAMfighter vandaag nog!
Dec 18 '06 #1
5 1180
Rik
Peertje wrote:
Hi group, I would like to show the latest aurora data on my site.
I know this is possible with help of a php-script, but I'm a nitwit
with php-scripting.
That's why I'm asking for help here.

The following url is being updated once every minute.
http://sec.noaa.gov/ftpdir/lists/ace/ace_mag_1m.txt
and contains data for the past 2 hours.

I would like to show the most recent Bx, By, Bz en Bt values (see
line 21)
as following:.
Bx=x.x By=x.x Bz=x.x Bt=x.x (where x.x is the most recent value)

Does anyone know how I can do this with a small script?
Help is highly appreciated !!
Dirty, but hardly quick:

<?php
$info =
file_get_contents('http://sec.noaa.gov/ftpdir/lists/ace/ace_mag_1m.txt');
preg_match('/
(?P<Bx>-?[0-9\.]+)\s*
(?P<By>-?[0-9\.]+)\s*
(?P<Bz>-?[0-9\.]+)\s*
(?P<Bt>-?[0-9\.]+)\s*
(?P<Lat>-?[0-9\.]+)\s*
(?P<Long>-?[0-9\.]+)\s*
$/sx',$info,$match);
var_dump($match);
?>

File_get_contents is rather slow, you might want to check out
http://www.php.net/manual/en/function.fseek.php to get comments on how to
get the last line quicker.
-------------------------------------------------------------------------
-------
Mijn Postvak In wordt beschermd door SPAMfighter
14181 spam-mails zijn er tot op heden geblokkeerd.
Download de gratis SPAMfighter vandaag nog!
This is unwanted spam. Either teach SPAMfighter not to use it, or use a sig
seperator (--(space)(newline)) before it, so it will be in your signature
instead of your 'real' post.
--
Rik Wasmus
Dec 18 '06 #2
On Mon, 18 Dec 2006 23:30:42 +0100, Peertje wrote:
Hi group, I would like to show the latest aurora data on my site.
I know this is possible with help of a php-script, but I'm a nitwit with
php-scripting.
That's why I'm asking for help here.

The following url is being updated once every minute.
http://sec.noaa.gov/ftpdir/lists/ace/ace_mag_1m.txt
and contains data for the past 2 hours.

I would like to show the most recent Bx, By, Bz en Bt values (see line 21)
errmmm. "the most recent" appears to be line 'LAST', not "line 21".

BTW, line 2 seems to be the timestamp of when the txt file is
(re)written -- with line 'LAST' being some 2 minutes older. (Probably
attributed to data gathering, processing, and dissemination
overhead.)

Jonesy
--
Marvin L Jones | jonz | W3DHJ | linux
38.24N 104.55W | @ config.com | Jonesy | OS/2
*** Killfiling google posts: <http//jonz.net/ng.htm>
Dec 18 '06 #3
Thanks for the very quick replies.
And sorry for the "spam".

You are right about the last line.
Saw it after I posted the thread ;-)

--------------------------------------------------------------------------------
Mijn Postvak In wordt beschermd door SPAMfighter
14181 spam-mails zijn er tot op heden geblokkeerd.
Download de gratis SPAMfighter vandaag nog!
Dec 18 '06 #4
Rik
Peertje wrote:
Thanks for the very quick replies.
And sorry for the "spam".
You're sorry, but you're not doing anything about it? Nice going.

It can be done: AFAIK you're using Outlook Express, so:

- get OEQuotefix, amust when using OE on newsgroups.
- add a custom signature for your newsgroup account

Voilá, the spam of this evil company that sais it's fighting spam is in a
signature, perfectly ignored by all normal readers (and also OE if you
indeed uses OEQuotefix.
--
Rik Wasmus
Dec 19 '06 #5
Peertje wrote:
Thanks for the very quick replies.
And sorry for the "spam".

You are right about the last line.
Saw it after I posted the thread ;-)

--------------------------------------------------------------------------------
Mijn Postvak In wordt beschermd door SPAMfighter
14181 spam-mails zijn er tot op heden geblokkeerd.
Download de gratis SPAMfighter vandaag nog!

The sig separator should be two dashes and a space ONLY, eg:

--
bill
Dec 19 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Baby Blue | last post by:
I have 2 code like below to grab a news website for my site. However, when I click some links (such as : http://wwww.vnexpress.net/xxx/xxxx ) inside the site which I want to grab, it has some...
3
by: Baby Blue | last post by:
I have 2 codes below to grap data from another site. I use them to get the data from one News site. However, when I click on some link inside (such as :...
12
by: Larry R. Baker | last post by:
Is it possible to grab a client side IP Address using JavaScript in an htm page? I have a web page hosted on a non-ASP server and I want a piece of code in JavaScript to grab the IP address of the...
6
by: dan glenn | last post by:
hi. I'm having a problem using javasript to pass the value of a textarea (in a form) to a PHP script file. I want to code a 'preview' function into a guestbook entry page, using an HTML link...
1
by: werdna.sivad | last post by:
In PHP is there a way to grab the HTTP Pipeline? I want to be able to grab all the HTML code that gets streamed to the user. I want to add the ability to send copies of a page as an email...
4
by: strawberry | last post by:
Say I have a chunk of text and I know that somewhere in that chunk ot text is the phrase 'Next Week's Winning Number will be:', is there a way I can automatically grab the string immediately...
5
by: Kentor | last post by:
Hello, how can I grab some information from other websites? Like for example the way housingmaps.com is grabbing stuff from craigslist.org ... Can someone redirect me to a few examples of where...
3
by: Oliver Marshall | last post by:
Hi chaps, I just need a widget of php if anyone has somethign similar to hand. I need to create a .php file that will take an input (&type=xxx or yyy), run a piece of javascript in the browser...
3
by: SM | last post by:
I'm using simpleXML in PHP and i Can't get this small piece of code to work? Need help I have an XML that looks like this: <?xml version="1.0" encoding="utf-8"?> <VIDEO> <item>...
2
by: lionbarrage | last post by:
Hi all, I was just wondering if anyone knows how to grab an image from a flv or a swf when a user uploads a file? Any help would be appreciated!
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.