LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-17-2009, 10:26 AM   #1
OverlordSquishy
LQ Newbie
 
Registered: Mar 2009
Posts: 1

Rep: Reputation: 0
Help separating a value


Hey,

I'm working on a project for a Web Server administration class. We can use either IIS or Apache for the project and I've chosen to use Apache because I have very little experience administrating Linux and Linux applications.

What I'm trying to do is retrieve stock information and use it to make an automated stock-trading program. So far, I've got as far as isolating the line containing the information I need, but haven't made much progress since.

I've got the line:
<td width="1%" class=val><span id="ref_694653_op">320.18</span></td>

and I need to be able to pull 320.18 out of the line. This value will change. I've looked into using awk and Perl to do this (as I have some, though little experience with both) and so far no luck.

Any help would be greatly appreciated.

Last edited by OverlordSquishy; 03-17-2009 at 11:43 AM.
 
Old 03-17-2009, 12:06 PM   #2
rizwanrafique
Member
 
Registered: Jul 2006
Distribution: Debian, Ubuntu, openSUSE, CentOS
Posts: 147

Rep: Reputation: 19
Try this one in perl:
Code:
#!/user/bin/perl

'<td width="1%" class=val><span id="ref_694653_op">320.18</span></td>' =~ m/<.*><.*>([0-9\.]+)<.*>/;

print $1;
This is a solution but a horrible one because HTML can't be relied upon for data at all. For example, imagine the scenario where the website inserts newline characters after each tag close. Try to find an xml/rss feed from the provider and then parse that. You'll get more reliable results.
 
Old 03-17-2009, 03:24 PM   #3
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 346

Rep: Reputation: 152Reputation: 152
Try
Code:
echo "$line" | sed 's/<[^>]*>//g'
320.18
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
separating GUI from code Four Programming 2 08-10-2008 09:16 PM
separating connections [AdultSwim] Linux - Networking 5 04-14-2007 12:48 PM
Separating multiple accounts in Evolution Frank616 Linux - Software 1 01-27-2006 10:25 PM
separating strings cxel91a Programming 3 05-01-2004 06:54 PM
separating words cxel91a Programming 14 04-29-2003 01:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration