Converting html table data into multiple variables.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Converting html table data into multiple variables.
# 1  
Old 02-28-2010
Converting html table data into multiple variables.

Hi,
Basically what I am trying to do is the following.

I have created a shell script to grab timetabling information from a website using curl then I crop out only the data I need which is a table based on the current date. It leaves me with a file that has the table I want plus a small amount of java script which I don't need.

The only thing I am interested in is the table which contains the timetable for that day.

I want to convert the html table into multiple variables so that I can later convert the data into either a text file or a rss file. The problem lies with the table depending on the day can have a different number of columns or rows.

How would I go about creating individual variables for each item in the table when the columns and rows change each day.

Thanks
dom
# 2  
Old 02-28-2010
Example data helps.
# 3  
Old 03-01-2010
Sorry about that

Attached is what I have cut from the html page

Code:
Monday
March 1 2010

<table width='100%' border='1' cellspacing='0' cellpadding='3'>        

<tr>
            
<th>Booking #</th>
<th>Client / UOS</th>
<th>Day</th>
<th>Times</th>
<th>Dates</th>
<th>Frequency</th>
<th>Capacity</th>
<th>Purpose</th>
<th>&nbsp;</th>
</tr>
                        
<tr>
<td>
                                        
<a href='bookingDetails.jsp?tempViewSingle=true&bookingId=595897'>595897</a>
</td>
                                    
                                        
<td><a href="https://www.unix.com/ttLabel.jsp?academicYear=2010&sessionId=1&labelString=LAWS1022&campusId=1">LAWS1022</a></td>
                                        
<td>MON</td>
<td>10:00 - 12:00</td>
<td>1 Mar 10 - 12 Apr 10</td>
<td>Weekly</td>
<td>20</td>
<td>Seminar</td>
                    
<td>
<a href='booking.jsp?level2=Edit&bookingId=595897'>Edit</a>
                        
&nbsp;</td>
                    
</tr>
                        
<tr>
<td>
<a href='bookingDetails.jsp?tempViewSingle=true&bookingId=595914'>595914</a>
</td>
                                        
                                        
<td><a href="https://www.unix.com/ttLabel.jsp?academicYear=2010&sessionId=1&labelString=LAWS1013&campusId=1">LAWS1013</a></td>
                                        
<td>MON</td>
<td>12:00 - 13:00</td>
<td>1 Mar 10 - 12 Apr 10</td>
<td>Weekly</td>                    
<td>20</td>
<td>Seminar</td>
<td>
                        
<a href='booking.jsp?level2=Edit&bookingId=595914'>Edit</a>
&nbsp;</td>
                    
</tr>
                        
<tr>
<td>
                                        
<a href='bookingDetails.jsp?tempViewSingle=true&bookingId=595900'>595900</a>
</td>
                                        
<td><a href="https://www.unix.com/ttLabel.jsp?academicYear=2010&sessionId=1&labelString=LAWS1022&campusId=1">LAWS1022</a></td>
                                        
<td>MON</td>
<td>14:00 - 16:00</td>
<td>1 Mar 10 - 12 Apr 10</td>
<td>Weekly</td>                    
<td>20</td>
<td>Seminar</td>
<td>
<a href='booking.jsp?level2=Edit&bookingId=595900'>Edit</a>
&nbsp;</td>
                    
</tr>
                        
</table>
<p>

Tuesday
March 2 2010

Basically each value between
Code:
<th> value </th><td> value </td>

is what I want to capture but sometimes the capacity column, frequency column or both columns are not always generated. So both the number of columns or number of rows can differ from day to day.

Last edited by domsmith; 03-01-2010 at 09:34 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Generate files and use csv data to replace multiple variables in a template

I have a source csv file consists of first field as variable name, and the rest are site-specific information (converted from excel file, where site -specific values in columns). I am trying to create a file for every site using a template and replace the multiple variables with values from the... (3 Replies)
Discussion started by: apalex
3 Replies

2. Linux

Parsing - export html table data as .csv file?

Hi all, Is there any out there have a brilliant idea on how to export html table data as .csv or write to txt file with separated comma and also get the filename of link from every table and put one line per rows each table. Please see the attached html and PNG of what it looks like. ... (7 Replies)
Discussion started by: lxdorney
7 Replies

3. Shell Programming and Scripting

Input data of a file from perl into HTML table

Hi , I need an help in perl scripting. I have an perl script written and i have an for loop in that ,where as it writes some data to a file and it has details like below. cat out.txt This is the first line this is the second line. .....Now, this file needs to be send in mail in HTML... (2 Replies)
Discussion started by: scott_cog
2 Replies

4. Shell Programming and Scripting

Creating html table from data in file

Hi. I need to create html table from file which contains data. No awk please :) In example, ->cat file num1 num2 num3 23 3 5 2 3 4 (between numbers and words single TAB). after running mycode i need to get (heading is the first line): <table>... (2 Replies)
Discussion started by: Manu1234567
2 Replies

5. Shell Programming and Scripting

awk -- Extract data from html within multiple tags as reference

Hi, I'm trying to get some data from an html file, but the problem is before it can extract the information I have multiple patterns that need to be passed through. https://www.unix.com/shell-programming-scripting/150711-extract-data-awk-html-files.html Is a similar problem. The only... (5 Replies)
Discussion started by: counfhou
5 Replies

6. UNIX for Advanced & Expert Users

Mutt for html body and multiple html & pdf attachments

Hi all: Been racking my brain on this for the last couple of days and what has been most frustrating is that this is the last piece I need to complete a project. There are numerous posts discussing mutt in this forum and others but I have been unable to find similar issues. Running with... (1 Reply)
Discussion started by: raggmopp
1 Replies

7. Shell Programming and Scripting

extract complex data from html table rows

I have bash, awk, and sed available on my portable device. I need to extract 10 fields from each table row from a web page that looks like this: </tr> <tr> <td>28 Apr</td> <td><a... (6 Replies)
Discussion started by: rickgtx
6 Replies

8. Shell Programming and Scripting

Bash shell script that inserts a text data file into an HTML table

hi , i need to create a bash shell script that insert a text data file into an html made table, this table output has to mailed.I am new to shell scripting and have a very minimum idea of shell scripting. please help. (9 Replies)
Discussion started by: intern123
9 Replies

9. UNIX for Dummies Questions & Answers

Bash script to insert data into an html table

hi, I need to create a bash shell script which picks up data from a text file and in the output file puts it into an html made table. I have to use sed and awk utilties to do this the input text file will contain data in the format: job name para1 para2 para3 para4 para4 1 ... (1 Reply)
Discussion started by: intern123
1 Replies

10. Shell Programming and Scripting

Converting HTML data into a spreadsheet

Hi, I have a perl script that prints some data in the form of a table (HTML table) Now, I want to be able to convert this data into a report on an Excel sheet. How can I do this? Regards, Garric (4 Replies)
Discussion started by: garric
4 Replies
Login or Register to Ask a Question