473,563 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2476
urls = [("/tmp/validate1.html" , "http://www.theage.com. au")]

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

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.cl ient.http.HTTPC lientProtocol.h tml>

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.or g/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.or g/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.or g/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************ *********@j44g2 000cwa.googlegr oups.com>,
"yaru22" <ya****@gmail.c omwrote:
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

"Periodical ly 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
2093
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 it should be a bug in the validator, but perhaps, I missed something. What do you think? Page: http://www.bcc.ufla.br/~lpgomes/ Validator:
0
7664
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.