Read html and get specific value


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Read html and get specific value
# 1  
Old 01-06-2012
MySQL Read html and get specific value

Hello guys Smilie

I have a specific small html file which looks like this:
Code:
<td><a href="/wiki/File:ABC_red_le_route.jpg" class="image" title="Chicago 'L' 2600 series train"><img alt="Chicago 'L' 2600 series train" src="example.com/random_image.com" width="550" height="255" /></a></td>

I want to take the text in bold above using sed or something (of course what's in there does change through time and so the command should actually read from the 1st match of ' " ' to the second match of it. Can you help me on this?

Thanks!
# 2  
Old 01-06-2012
See if this works for you:
Code:
sed 's/.*"\(.*\)" class.*/\1/' File

# 3  
Old 01-06-2012
Works like a charm Smilie Thank you Smilie

---------- Post updated at 05:42 PM ---------- Previous update was at 01:35 PM ----------

Oh, and as it has to do with the same thing, can you help me with this as well?
The file contains:
Code:
<li><a href="#globalusage">Global file usage</a></li></ul><div class="fullImageLink" id="file"><a href="//abc.com/abc.jpg"><img alt="File:ABC.jpg" src="//abc.abc.com/abc.png" width="800" height="371" /></a><br /><small>Size of this preview: <a href="//abc.abc.com/abceefed.png" class="mw-thumbnail-link">800 × 371 pixels</a>.</small> <small>Other resolutions: <a href="//abc.abc.com/abdddc.png" class="mw-thumbnail-link">320 × 149 pixels</a>*| <a href="//abc.abcd.com/asdfbc.png" class="mw-thumbnail-link">640 × 297 pixels</a>*| <a href="//abc.dfrre/ghtmd.jpg" class="mw-thumbnail-link">1,024 × 475 pixels</a>*| <a href="//abc.abc.com/abdec.png" class="mw-thumbnail-link">1,280 × 594 pixels</a>.</small></div>

The desired output is being highlighted!

Thanks again Smilie
# 4  
Old 01-07-2012
Try this...
Code:
awk -F"[=\"]" '{print $12}' infile

#or

sed 's/.*href="\(.*jpg\)">.*/\1/1' f

--ahamed
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How is html code read, compared to say python?

so, the first line of bash, perl, python, ruby, and similar languages must contain the path to the interpreter...i.e. #!/bin/perl, or #!/bin/python. so in the case of a perl script, for instance, a perl script cannot and will never run if the perl program is not installed/present on the system. ... (9 Replies)
Discussion started by: SkySmart
9 Replies

2. UNIX for Dummies Questions & Answers

Read data from excel and upload into html page

Hi, I have requirement for automation, wanna confirm whether is it possible in shell scripting. 1) Need to read data from excel sheet 2) And upload the details in html page I know first requirement is possible by converting excel into csv form, but not sure about the second one. If... (6 Replies)
Discussion started by: stew
6 Replies

3. Shell Programming and Scripting

Script that gathers specific values from files and puts it into HTML to send e-mail

Hi All, Sorry for long topic here. So the drill goes like that, I need a script which gathers different values from different files/locations. A_CT=`cat a.dat | awk -F'|' '{print $1}' >> report.txt` B_CT=`cat b.dat | awk -F'|' '{print $3}' >> report.txt` C_CT=`cat c.dat | awk -F'|'... (4 Replies)
Discussion started by: shivakid
4 Replies

4. Shell Programming and Scripting

Extract specific line in an html file starting and ending with specific pattern to a text file

Hi This is my first post and I'm just a beginner. So please be nice to me. I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file? I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies

5. Shell Programming and Scripting

[SOLVED] Read html attachment from /var/mail

Hi, I am receiving an email to the server with a html attachment. When I check the /var/mail the attachment is showing as junk characters. I want to move that html file to a particular location in that server. Please help me. Regards Neethu (4 Replies)
Discussion started by: Neethu
4 Replies

6. Shell Programming and Scripting

Read html attachment

Hi, I will get an email with a html attachment. I want to copy that html file to server in a particular location. Is it possible to do this.. If yes could you please help me on this.. Regards Neethu (1 Reply)
Discussion started by: Neethu
1 Replies

7. Shell Programming and Scripting

Using awk to read a specific line and a specific field on that line.

Say the input was as follows: Brat 20 x 1000 32rf Pour 15 p 1621 05pr Dart 10 z 1111 22xx My program prompts for an input, what I want is to use the input to locate a specific field. Like if I type in, "Pou" then it would return "Pour" and just "Pour" I currently have this line but it is... (6 Replies)
Discussion started by: Bungkai
6 Replies

8. Shell Programming and Scripting

Html parsing - get line after specific string till a point

Hi all :) It sounds complex, for example I want to find the whole html file (there are 5 entries of this string and I need to get all of them) for the string "<td class="contentheading" width="100%">", get the next line from it only till the point that says "</td>", plus removing \t (tabs) ... (6 Replies)
Discussion started by: hakermania
6 Replies

9. Emergency UNIX and Linux Support

Grab total page read from webalizer display in html

Hi, I need a way to grab the total combines since inception, total pages read from webalizer on my centos server or any other location (as long as since inception) and display the result live on my website So with each visit it would be increasing, or perhaps live (ajax) not sure But can... (0 Replies)
Discussion started by: lawstudent
0 Replies

10. Shell Programming and Scripting

Read a file and put it in HTML format

Hi, I have one file as follows and I need to read this file contents in an HTML format. And send html file to some mail ids using sendmail. Communications Pvt Ltd Report AccountId Name Code IdBill Balance ... (3 Replies)
Discussion started by: Kattoor
3 Replies
Login or Register to Ask a Question