1

I am trying to access and manipulate the data of the web page. For primary testing purpose I used the w3schools websit but I am unable to access the content using following code:

import urllib as url
import xml.etree.ElementTree as et

web_data = url.urlopen("www.w3schools.com/xml/cd_catalog.xml")
str_data = web_data.read()
print str_data

These are the errors I am getting :

Traceback (most recent call last):
  File "C:\Python27\webpage.htlm.py", line 4, in <module>
    web_data = url.urlopen("www.w3schools.com/xml/cd_catalog.xml")
  File "C:\Python27\lib\urllib.py", line 87, in urlopen
    return opener.open(url)
  File "C:\Python27\lib\urllib.py", line 213, in open
    return getattr(self, name)(url)
  File "C:\Python27\lib\urllib.py", line 469, in open_file
    return self.open_local_file(url)
  File "C:\Python27\lib\urllib.py", line 483, in open_local_file
    raise IOError(e.errno, e.strerror, e.filename)
IOError: [Errno 2] The system cannot find the path specified: 'www.w3schools.com\\xml\\cd_catalog.xml'
3
  • open_file/open_local_file means it's looking for that file on your computer, not on the internet... Commented Jul 30, 2015 at 10:52
  • 1
    Try adding http:// before your URL. Commented Jul 30, 2015 at 10:53
  • 1
    URLs start with a protocol. Add http://... Commented Jul 30, 2015 at 10:53

1 Answer 1

4

A URL begins with a protocol.

Here, you probably wanted http://www.w3schools.com/xml/cd_catalog.xml.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.