472,371 Members | 1,616 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Python program that validates an url against w3c markup validator

I'd like to create a program that validates bunch of urls against the
w3c markup validator (http://validator.w3.org/) and store the result in
a file.

Since I don't know network programming, I have no idea how to start
coding this program.

I was looking at the python library and thought urllib or urllib2 may
be used to make this program work.

But I don't know how to send my urls to the w3c validator and get the
result.

Can anyone help me with this? or at least give me a hint?

Thank you so much.

Nov 29 '06 #1
6 2408
urls = [("/tmp/validate1.html", "http://www.theage.com.au")]

for url, outputfile in urls:
commandString = 'wget -o %s http://validator.w3.org/check?uri=%s' %
(outputfile, url)
system.exec(commandString)

is one easy way.

yaru22 wrote:
I'd like to create a program that validates bunch of urls against the
w3c markup validator (http://validator.w3.org/) and store the result in
a file.

Since I don't know network programming, I have no idea how to start
coding this program.

I was looking at the python library and thought urllib or urllib2 may
be used to make this program work.

But I don't know how to send my urls to the w3c validator and get the
result.

Can anyone help me with this? or at least give me a hint?

Thank you so much.
Nov 29 '06 #2
yaru22 wrote:
I was looking at the python library and thought urllib or urllib2
may be used to make this program work.

But I don't know how to send my urls to the w3c validator and get
the result.
Another great alternative is using the Twisted framework:

<http://twistedmatrix.com/projects/co...ntation/howto/
index.html>
<http://twistedmatrix.com/documents/current/api/
twisted.web2.client.http.HTTPClientProtocol.html>

Once you get familiar with the style of Twisted code, it's quite
easy to many write clients and servers because most protocols are
already implemented and must only be adapted to your needs.

Regards,
Björn

--
BOFH excuse #40:

not enough memory, go get system upgrade

Nov 29 '06 #3
yaru22 wrote:
I'd like to create a program that validates bunch of urls against the
w3c markup validator (http://validator.w3.org/) and store the result in
a file.

Since I don't know network programming, I have no idea how to start
coding this program.

I was looking at the python library and thought urllib or urllib2 may
be used to make this program work.

But I don't know how to send my urls to the w3c validator and get the
result.
this should get you going, I think:
>>import urllib
uri = "http://www.python.org"
f = urllib.urlopen("http://validator.w3.org/check?uri=" + uri)
print f.headers
Date: Wed, 29 Nov 2006 06:52:33 GMT
Server: Apache/2.0.54 (Debian GNU/Linux) mod_perl/1.999.21 Perl/v5.8.4
Content-Language: en
X-W3C-Validator-Recursion: 1
X-W3C-Validator-Status: Valid
X-W3C-Validator-Errors: 0
Connection: close
Content-Type: text/html; charset=utf-8
>>print f.headers["x-w3c-validator-status")
Valid
>>uri = "http://www.cnn.com"
f = urllib.urlopen("http://validator.w3.org/check?uri=" + uri)
print f.headers["x-w3c-validator-status"]
Invalid
>>print f.headers["x-w3c-validator-errors"]
39

</F>

Nov 29 '06 #4
Fredrik Lundh wrote:
>>f = urllib.urlopen("http://validator.w3.org/check?uri=" + uri)
>>print f.headers
here's the specification, btw:

http://validator.w3.org/docs/api.html

</F>

Nov 29 '06 #5
At Wednesday 29/11/2006 02:29, yaru22 wrote:
>I'd like to create a program that validates bunch of urls against the
w3c markup validator (http://validator.w3.org/) and store the result in
a file.

Since I don't know network programming, I have no idea how to start
coding this program.
Why not use the standalone validator? You can download and install it.
--
Gabriel Genellina
Softlab SRL

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
Nov 29 '06 #6
In article <11*********************@j44g2000cwa.googlegroups. com>,
"yaru22" <ya****@gmail.comwrote:
I'd like to create a program that validates bunch of urls against the
w3c markup validator (http://validator.w3.org/) and store the result in
a file.

Since I don't know network programming, I have no idea how to start
coding this program.

I was looking at the python library and thought urllib or urllib2 may
be used to make this program work.

But I don't know how to send my urls to the w3c validator and get the
result.

Can anyone help me with this? or at least give me a hint?

Thank you so much.
This article might be of help:
http://www.standards-schmandards.com/2005/massvalidate

"Periodically you may want to make sure your entire website validates.
This can be a hassle if your site is big. In this article we introduce a
few python scripts which will help us do mass validation from a list of
links. We will also modify the W3C validator to work the way we want."

You might also be interested in my validating spider (see my sig) which
will validate an entire site for you but that won't teach you a thing
about Python programming. ;)

--
Philip
http://NikitaTheSpider.com/
Whole-site HTML validation, link checking and more
Nov 29 '06 #7

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

Similar topics

2
by: Bruno Schneider | last post by:
I've seen this page, that seems invalid to me. Doctype is incomplete and it does not have a <bodytag. However, W3C validator validates it as HTML 4.01 strict, even when I force the DOCTYPE. I think...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.