Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: exception in urllib2

Reply
Thread Tools

Re: exception in urllib2

 
 
7stud
Guest
Posts: n/a
 
      02-01-2009
On Feb 1, 3:34*am, asit <(E-Mail Removed)> wrote:
> I hv been developing a link scanner. Here the objective is to
> recursively scan a particular web site.
>
> During this, my script methttp://images.google.co.in/imghp?hl=en&tab=wi
> and passed it to the scan function, whose body is like this..
>
> def scan(site):
>


So you have this:

site=http://images.google.co.in/imghp?hl=en&tab=wi

??



> * * log=open(logfile,'a')
> * * log.write(site + "\n")
> * * site = "http://" + site.lower()
>


So now:

site = "http://" + "http://images.google.co.in/imghp?hl=en&tab=wi"

Hmmm...let's see what happens when I run the following program:


import urllib

site = "http://" + "http://images.google.co.in/imghp?hl=en&tab=wi"
html = urllib.urlopen(site)

--output:--
Traceback (most recent call last):
File "6test.py", line 4, in ?
html = urllib.urlopen(site)
File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
python2.4/urllib.py", line 82, in urlopen
return opener.open(url)
File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
python2.4/urllib.py", line 190, in open
return getattr(self, name)(url)
File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
python2.4/urllib.py", line 303, in open_http
h = httplib.HTTP(host)
File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
python2.4/httplib.py", line 1097, in __init__
self._setup(self._connection_class(host, port, strict))
File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
python2.4/httplib.py", line 586, in __init__
self._set_hostport(host, port)
File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
python2.4/httplib.py", line 598, in _set_hostport
raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
httplib.InvalidURL: nonnumeric port: ''


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
urllib2 httplib.BadStatusLine exception while opening a page on anOracle HTTP Server ak Python 7 03-01-2009 09:22 PM
Exception of type 'System.Web.HttpUnhandledException' wasthrown.Exception has been thrown by the target of an invocation.System.WebSystem.Exception jobs ASP .Net 1 11-16-2007 05:57 PM
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
Problem with: urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) Josef Cihal Python 0 09-05-2005 11:26 AM
Re: bizaar exception that isn't really an exception jeff ASP .Net 0 06-24-2003 12:46 PM



Advertisments