Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > sample code for parsing html file to get contents of td fields

Reply
Thread Tools

sample code for parsing html file to get contents of td fields

 
 
yaffa
Guest
Posts: n/a
 
      08-04-2005
does anyone have sample code for parsting an html file to get contents
of a td field to write to a mysql db? even if you have everything but
the mysql db part ill take it.

thanks

yaffa

 
Reply With Quote
 
 
 
 
William Park
Guest
Posts: n/a
 
      08-04-2005
yaffa <> wrote:
> does anyone have sample code for parsting an html file to get contents
> of a td field to write to a mysql db? even if you have everything but
> the mysql db part ill take it.


I usually use Expat XML parser to extract the field.
http://home.eol.ca/~parkw/index.html#expat

Expat is everywhere. Python has it and even Gawk has it.

--
William Park <>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/
 
Reply With Quote
 
 
 
 
Bill Mill
Guest
Posts: n/a
 
      08-04-2005
On 4 Aug 2005 11:54:38 -0700, yaffa <> wrote:
> does anyone have sample code for parsting an html file to get contents
> of a td field to write to a mysql db? even if you have everything but
> the mysql db part ill take it.
>


Do you want something like this?

In [1]: x = "something <td><b>something</b> else</td> and\nanother thing <td>in
a td</td> and again else"

In [2]: import re

In [3]: r = re.compile('<td>(.*?)</td>', re.S)

In [4]: r.findall(x)
Out[4]: ['<b>something</b> else', 'in a td']

If not, you'll have to explain more clearly what you want.

Peace
Bill Mill
bill.mill at gmail.com
 
Reply With Quote
 
Kent Johnson
Guest
Posts: n/a
 
      08-04-2005
yaffa wrote:
> does anyone have sample code for parsting an html file to get contents
> of a td field to write to a mysql db? even if you have everything but
> the mysql db part ill take it.


http://www.crummy.com/software/Beaut.../examples.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding contents on yaml file without overwriting actual contents Kamarulnizam Rahim Ruby 4 01-28-2011 09:10 AM
looking for asp.net sample with vb.net backend sample is there one? Jake ASP .Net 0 02-09-2006 10:44 PM
Newbie - Reading a file with delimited fields, storing first two fields in a hash AMT2K5 Perl Misc 1 11-08-2005 01:06 AM
reading parameter file and parsing the contents easy C++ 2 03-19-2005 02:51 AM
will the following html code submit the contents of the file? Guy HTML 2 12-05-2003 03:48 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57