fetch substring from html code


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting fetch substring from html code
# 1  
Old 05-28-2008
fetch substring from html code

hello mates.
please help me out once again.
i have a html file where i want to fetch out one value from the entire html-code

sample html code:
Code:
.....
 <b>Amount:<b> 12345</div>
...

now i only want to fetch the 12345 from the html document.

how to i tell sed to get me the value from between <b>Amount<b> and </div>

thanks guys
# 2  
Old 05-29-2008
I guess you probably know that isn't even valid HTML. Presuming you have a vaild </b> end tag in reality, try this;

Code:
sed -n 's%<b>Amount:</b>\([^<>]*\)</div>%\1%p' file.html

If you really do have a HTML syntax error there, take out the slash in the </b> tag.

This finds a line matching the pattern, replaces it with just the part between the \( parentheses \) and prints it. If there are multiple such lines, they will all be printed.
# 3  
Old 05-29-2008
thanks man, the <b> was a typo.
nice you care so much.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Fetch entries with tags with editing in existing code

Hi all I have to make some changes in the following code to fetch some more entries in the attached file. awk 'k>0 {if (a && k==2) { print a":"a":"a; a=a=a="";} a=a?a" "$0:$0; k=0;} /^# Drug_Target_.*_Gene_Name/ {k=3;} /^# Generic/ {k=1;} /^# Brand_Name/ {k=2;} END {if (a) print a" "a" "a;}'... (6 Replies)
Discussion started by: manigrover
6 Replies

2. Shell Programming and Scripting

Script to fetch data from HTML

Hi All, There is a link from were I usually search somthing and fetch the data from. Is there any way to automate it through a script if I mention search criteria in a note pad. I mean the script to search the content on the notepad and resutls should be placed into another file. ... (2 Replies)
Discussion started by: indradev
2 Replies

3. Ubuntu

Fetch html page convert to pdf automatically via cmd or other means, shortcut

Hi, Im used to compiling when i stumble upon some interesting topics in the net and convert it into pdf files unto my HD for future reference's. I using the chrome print to pdf procedure since firefox html to pdf don't work correctly. I just wonder in someone do same thing and did it in a easy... (3 Replies)
Discussion started by: jao_madn
3 Replies

4. Shell Programming and Scripting

html code in SQL query

Hi expert, I have a script which is connecting with sql internally, fetch same data, store it in a file and then from os I cat this file and sending it to mail (windows outlook). This is working fine, I just need to know wether we can add some html codes with the sql query like we can add... (0 Replies)
Discussion started by: mcagaurav
0 Replies

5. Shell Programming and Scripting

harvesting posts from html code

How could I use sed to find a string, then take the contents of the next line to a new file? I want to try to collect data from thread. If I look at the html for the page, it seems like I can cut out all the junk by keying on the phrase <div class="postmsg"> then printing the next line to a new... (1 Reply)
Discussion started by: audiophile
1 Replies

6. Shell Programming and Scripting

HTML code remove

Hello, I have one file which has been inserted intermittently with HTML web page. I would like to remove all text between "<html xmlns="http://www.w3.org/1999/xhtml">" and </html> tags. Can any one please suggest me sed regular expression for it. Thanks (3 Replies)
Discussion started by: nrbhole
3 Replies

7. Shell Programming and Scripting

Extract URLs from HTML code using sed

Hello, i try to extract urls from google-search-results, but i have problem with sed filtering of html-code. what i wont is just list of urls thay apears between ........<p><a href=" and next following " in html code. here is my code, i use wget and pipelines to filtering. wget works, but... (13 Replies)
Discussion started by: L0rd
13 Replies

8. Shell Programming and Scripting

how to fetch substring from records into another file

Hi all, Im stuck in findind solution to ths problem. Please guide me if u have any ideas. I have two files. ===FILE1=== >bi|2138271|geb|AAC15885.1|precursor MRVIAAAMLYLYIVVLAICSVGIQGIDYPSVSFNLAGAKSATWDFLRMPHDLVGEDNKYNDGEPITGNII... (25 Replies)
Discussion started by: smriti_shridhar
25 Replies

9. Shell Programming and Scripting

How to sca a sequential file and fetch some substring data from it

Hi, I have a task where i need to scan second column of seuential file and fetch first 3 digits of that column For e.g. FOLLOWING IS THE SAMPLE FOR MY SEQUENTIAL FILE AU_ID ACCT_NUM CRNCY_CDE THHSBC001 30045678 THB THHSBC001 10154267 THB THHSBC001 ... (2 Replies)
Discussion started by: manmeet
2 Replies

10. Shell Programming and Scripting

Unix code to fetch the first field till space in a variable

Hi, I want to get the value of the first field till space in a variable. e.g x=323 /test/personel/logs/File1 I want to get the first field till space i.e 323 in another variable ,lets say y. echo $x|cut -d' ' -f1 gives 323 but when I'm trying y=`echo $x|cut -d' ' -f1 its giving... (3 Replies)
Discussion started by: autosys_nm
3 Replies
Login or Register to Ask a Question