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 > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Extract content from several txt-files larsu Shell Programming and Scripting 7 06-17-2008 03:52 AM
Content extract of a file using awk nr_shan Shell Programming and Scripting 5 12-19-2007 05:22 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
sending mail with html content gmchoudary UNIX for Dummies Questions & Answers 2 11-28-2005 08:26 AM
mail: html content RishiPahuja Shell Programming and Scripting 2 10-31-2005 12:43 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 03-04-2009
stargazerr stargazerr is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 12
sed to extract HTML content

Hiya,

I am trying to extract a news article from a web page. The sed I have written brings back a lot of Javascript code and sometimes advertisments too. Can anyone please help with this one ??? I need to fix this sed so it picks up the article ONLY (don't worry about the title or date .. i got those using a separate sed) ..

The sed I am running is:

tr -d '\n' <03climate.html | sed -e 's/»//g' -e 's/.*nyt_text[^;]*;//' -e 's/<\/p>.*//g' -e 's/<[^>]*>//g' -e s'/[&][#]//g' -e 's/<[^>]*>//g' >> articletest

The file I am trying to extract from (03climate.html) and the result (articletest.txt) are both attached with this post ..

Thanks.
SG
Attached Files
File Type: html 03climate.html (60.0 KB, 31 views)
File Type: txt articletest.txt (4.5 KB, 31 views)
  #2 (permalink)  
Old 03-18-2009
aaaaargh aaaaargh is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 20
IMO, its really a bad idea to parse HTML files using SED/AWK

Your best bet is to use PERL,

HTML::TreeBuilder - Parser that builds a HTML syntax tree - search.cpan.org
  #3 (permalink)  
Old 03-21-2009
septima.pars's Avatar
septima.pars septima.pars is offline
Registered User
  
 

Join Date: Jan 2009
Location: Chicago
Posts: 31
This is an interesting post...

I am wondering if there is a shell utility like the poppler tools (which convert pdf format to text), which perform conversion of html to text? Maybe I am asking the same question please advise................................
Closed Thread

Bookmarks

Tags
html, news article, sed, shell script, unresolved

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 02:49 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