473,383 Members | 1,843 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,383 software developers and data experts.

is there a bug in urlunparse/urlunsplit

Hi all.

Is there a bug in the urlunparse/urlunsplit functions?
Look at this fragment (I know is quite silly):

urlunparse(urlparse('www.example.org','http'))
---'http:///www.example.org'
^^^^^

There are too many slashes, isn't it? Is it a known bug or maybe I
missed something...

Alex

Jun 27 '08 #1
2 1432
Alex wrote in news:09764c57-03ce-4ccb-a26d-
e8**********@a23g2000hsc.googlegroups.com in comp.lang.python:
Hi all.

Is there a bug in the urlunparse/urlunsplit functions?
Look at this fragment (I know is quite silly):

urlunparse(urlparse('www.example.org','http'))
---'http:///www.example.org'
^^^^^
Try these 3:

urlparse('www.example.org','http')
urlparse('http://www.example.org','http')
urlparse('//www.example.org','http')

The 1st returns www.example.org as the path part
with the other 2 its the location (domain) part.

Although it may not be immediately obvious that the result
is correct, consider the follwing html fragment:

<img src="aaa.gif">
<img stc="http://anothersite.com/bbb.gif">

If you were to use urlparse to parse the src attributes
you would want:

( '', '', 'aaa.gif', '','','' )
( 'http', 'anothersite.com', '/bbb.gif', '','','' )
Which AIUI is what urlparse does.
Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jun 27 '08 #2
In article
<09**********************************@a23g2000hsc. googlegroups.com>,
Alex <me************@gmail.comwrote:
Hi all.

Is there a bug in the urlunparse/urlunsplit functions?
Look at this fragment (I know is quite silly):

urlunparse(urlparse('www.example.org','http'))
---'http:///www.example.org'
^^^^^

There are too many slashes, isn't it? Is it a known bug or maybe I
missed something...
Hi Alex,
For a few years now I've been using Fourthought's libraries for parsing
URLs and they've performed beautifully. In the code comments, they state
that urlparse() and friends exhibit some non-RFCish behavior, hence the
inspiration for writing their own libraries.

If I remember correctly, the file you want is uri.py and it is in 4Suite
which you can download from here:
http://www.fourthought.com/

HTH

--
Philip
http://NikitaTheSpider.com/
Whole-site HTML validation, link checking and more
Jun 27 '08 #3

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

Similar topics

4
by: Fuzzyman | last post by:
In a nutshell - the question I'm asking is, how do I make a socket conenction go via a proxy server ? All our internet traffic has to go through a proxy-server at location 'dav-serv:8080' and I...
18
by: AdSR | last post by:
Fellow Pythonistas, Please check out http://spyced.blogspot.com/2005/04/how-well-do-you-know-python-part-3.html if you haven't done so yet. It appears that you can specify a function...
1
by: whitemice | last post by:
The only documentation regarding doing authentication for XML-RPC I can find is - "Both the HTTP and HTTPS transports support the URL syntax extension for HTTP Basic Authentication:...
2
by: Robert Hancock | last post by:
Python 2.5.2 (r252:60911, Aug 28 2008, 23:51:17) on linux2 Type "help", "copyright", "credits" or "license" for more information. Traceback (most recent call last): File "<stdin>", line 1, in...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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.