The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
break out of 'if' finalight Shell Programming and Scripting 7 11-19-2008 03:54 PM
Converting HTML data into a spreadsheet garric Shell Programming and Scripting 4 04-22-2008 10:00 AM
extract data from html tables Streetrcr UNIX for Dummies Questions & Answers 8 03-20-2008 06:14 AM
How do I extract text only from html file without HTML tag los111 UNIX for Dummies Questions & Answers 4 11-28-2007 04:40 AM
coverting html data to text in 'c' phani_sree High Level Programming 3 10-18-2007 10:06 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-19-2008
phip phip is offline
Registered User
  
 

Join Date: May 2008
Posts: 1
To Break data out of HTML

I'm working with the output of an html form and trying to get it into CSV. The html is a table with many entries like the following.

HTML Code:
<tr><td nowrap><b><font size=3>NAME</font></b></td><td nowrap><b>License #  : </b>&nbsp;LICENSE</td></tr>
<tr><td><b>City : </b>&nbsp;CITY<td nowrap><b>Type  : </b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TYPE</td></tr>
<tr><td><b>State :</b>&nbsp;ST<td nowrap><b>Status  : </b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;STATUS</td></tr>
<tr><td><b>Phone :</b>&nbsp;PHONE<td nowrap><b>Expires: &nbsp;</b>&nbsp;&nbsp;&nbsp;&nbsp;EXPIRES</td></tr><td></td>
<td nowrap><b>Nat. Registry: </b>Y/N</td></tr><tr><td> <tr><td colspan=2><hr width='100%'></td></tr>
I'm looking for a way to turn that into
Code:
NAME, LICENSE, CITY, TYPE, ST, STATUS, PHONE, EXPIRES, Y/N
I was looking at sed, with \1, \2, etc, but it doesn't behave the way my understanding leads me to expect. My first thought was something like the following, but it seems way too fragile.

Code:
cat appr-test | sed 's_<tr><td nowrap><b><font size=3>\(.*\)</font>_\1'_
Is there a best way to go about this? Many thanks for ideas.
  #2 (permalink)  
Old 05-20-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
If you really want a "best way", that would be a proper HTML parser.

Assuming you wish to stay with something lighter, like sed or awk, perhaps you can elaborate on what is wrong with the sed you have tried so far. (The <font> tag in your example script does not occur in the HTML sample you posted, but I guess that's beside the point here.)
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0