473,378 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

creat a DOM from an html document

I thought I saw a package that would create a DOM from html, with
allowances that it would do a "best effort" job to parse
non-perfectly formed html.

Now I can't seem to find this... does anybody have a recommendation
as to a good package to look at?

Many TIA!
Mark
Feb 7 '06 #1
4 1165
Mark Harrison <mh@pixar.com> wrote:
Now I can't seem to find this... does anybody have a recommendation
as to a good package to look at?


Ahh, it's BeautifulSoup...

Thanks All!!
Feb 7 '06 #2
Mark Harrison <mh@pixar.com> writes:
Mark Harrison <mh@pixar.com> wrote:
Now I can't seem to find this... does anybody have a recommendation
as to a good package to look at?


Ahh, it's BeautifulSoup...


Strictly that's not THE DOM, just A document object model. The DOM
proper is a standardised interface, which BeautifulSoup does not
implement. You could build a DOM using BeautifulSoup, though.
John

Feb 9 '06 #3
John J. Lee wrote:
Mark Harrison <mh@pixar.com> writes:
Ahh, it's BeautifulSoup...


Strictly that's not THE DOM, just A document object model. The DOM
proper is a standardised interface, which BeautifulSoup does not
implement. You could build a DOM using BeautifulSoup, though.


For a certain value of standardised, libxml2dom provides "the DOM" for
HTML:

import urllib, libxml2dom
f = urllib.urlopen("http://www.python.org")
s = f.read(); f.close()
d = libxml2dom.parseString(s, html=1)
print "There are", len(d.xpath("//table")), "tables in the document."

See http://www.python.org/pypi/libxml2dom for more information.

Paul

Feb 9 '06 #4
Mark Harrison wrote:
I thought I saw a package that would create a DOM from html, with
allowances that it would do a "best effort" job to parse
non-perfectly formed html.

Now I can't seem to find this... does anybody have a recommendation
as to a good package to look at?

Many TIA!
Mark

While it doesn't generate a W3C DOM, BeautifulSoup is probably your best
bet for parsing less-than-perfect HTML and get something useable out of it.

Once you have your (parsed) document, you can either use it as is or try
to convert it to a valid W3C DOM though.
Feb 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: blossoming_hearts | last post by:
now i have problem i.e how 2 creat a web browser ? can any1 help me on this which languge i need 2 know what other things i need 2 know to make a web browser ? plz. help
3
by: David Barker | last post by:
I wish knowledge as to creat a Bibilical data index i.e. Genesis to Revelations not alphabetical! Can this be done using "Advance filtering"? and How?... I wish to be able to index a text that I'm...
10
by: Rock | last post by:
Hi, I want to create this.. A 2 col table with 3 rows down. In the 1st col I want three thumb size images, 1 in each row When an image is rolled on, the larger image shows up in col 2
2
by: Boki | last post by:
Hi All, Dim myMail Set myMail = CreateObject("CDONTS.NewMail") it shows "ActiveX can't creat object" error message, what should I do? Does that mean I have to add some .bas file? Could you...
2
by: macedo.silva | last post by:
Hi, I would like to request your attention for this very specific issue: I have several classes in Python, and now I want simply re-use it, in other language. The closest to solution I...
2
by: mohamed27 | last post by:
hi : i have a html site and i need to publish this site through domain name in the internet . i have a didicated server wih OS win 2003 server and iis 6 so i need to explore it . also i need...
0
by: dhanuka | last post by:
please i need u are help ! i would like to creat programe can not be affect in end task as we creat program in vb in that program can be remove through end task program so i need the program to...
1
by: dhanuka | last post by:
hai i hop to creat a program in vb, it must be a registration form through the program we have to add some details for this program Ex - we have to add some persons details i can creat that...
0
by: Jason7899 | last post by:
hi, i use the crystal report for creat reports and print all that i want in vb or vb.net now i looking for a such like crystal report for use in php or html all data is retrieve from a mysql...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.