469,282 Members | 2,320 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

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

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

Aug 4 '05 #1
3 1729
yaffa <ya*********@gmail.com> 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 <op**********@yahoo.ca>, 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/
Aug 4 '05 #2
On 4 Aug 2005 11:54:38 -0700, yaffa <ya*********@gmail.com> 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
Aug 4 '05 #3
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
Aug 4 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Xavier | last post: by
1 post views Thread by Ria | last post: by
1 post views Thread by leguvan | last post: by
1 post views Thread by =?Utf-8?B?R2hpc3Rvcw==?= | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.