| | |
Python and the internet
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jun 2009
Posts: 28
Reputation:
Solved Threads: 0
Right, so I looked at some python tutorials about interfacing with internet, but every time a use a code such as:
It just comes up with a load of error messages.
how can i sort this
Python Syntax (Toggle Plain Text)
import urllib pagetext = urllib.urlopen("http://www.python.org.html").read() print pagetext
how can i sort this
If you are using Python2 ...
For Python3 use ...
python Syntax (Toggle Plain Text)
import urllib pagetext = urllib.urlopen("http://www.python.org").read() print pagetext
python Syntax (Toggle Plain Text)
import urllib.request pagetext = urllib.request.urlopen("http://www.python.org").read() print(pagetext)
May 'the Google' be with you!
•
•
Join Date: Jun 2009
Posts: 28
Reputation:
Solved Threads: 0
Using 2.5.4:
came up with
came up with
Python Syntax (Toggle Plain Text)
Traceback (most recent call last): File "C:/Python25/urltest.py", line 2, in <module> pagetext = urllib.urlopen("http://www.python.org").read() File "C:\Python25\Lib\urllib.py", line 82, in urlopen return opener.open(url) File "C:\Python25\Lib\urllib.py", line 190, in open return getattr(self, name)(url) File "C:\Python25\Lib\urllib.py", line 325, in open_http h.endheaders() File "C:\Python25\lib\httplib.py", line 860, in endheaders self._send_output() File "C:\Python25\lib\httplib.py", line 732, in _send_output self.send(msg) File "C:\Python25\lib\httplib.py", line 699, in send self.connect() File "C:\Python25\lib\httplib.py", line 667, in connect socket.SOCK_STREAM): IOError: [Errno socket error] (11001, 'getaddrinfo failed')
Strange ...
... works just fine with Python 2.5.4
You could try the improved version ...
python Syntax (Toggle Plain Text)
import urllib pagetext = urllib.urlopen("http://www.python.org").read() print pagetext
You could try the improved version ...
python Syntax (Toggle Plain Text)
import urllib2 pagetext = urllib2.urlopen("http://www.python.org").read() print pagetext
Last edited by vegaseat; Jul 3rd, 2009 at 4:09 pm.
May 'the Google' be with you!
Yep, no errors whatsoever with my Python 2.5.4 installation either...
"Two good old boys in a fire-apple red convertible. Stoned. Ripped. Twisted. Good people."
- Hunter S. Thompson
my photography
- Hunter S. Thompson
my photography
![]() |
Similar Threads
- Starting Python (Python)
- Remote Python terminal via Internet (Python)
- Internet Explorer specialist needed (Web Development Job Offers)
- Reading ints from a file and creating a list with them. (Python)
- Python internet / IM (Python)
- Telecommute Python Programmer $4,000 (USD) (Web Development Job Offers)
- Python and the JPEG Image File, Part 1, The Header (Python)
Other Threads in the Python Forum
- Previous Thread: do-while loop in python
- Next Thread: (text) summary screen during large data conversion
Views: 312 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for Python
accessdenied address ansi backend beginner changecolor class code conversion coordinates copy corners curves customdialog dan08 dictionary directory dynamic edit examples excel feet file float font format ftp function generator getvalue gui halp homework i/o iframe images import info input ip java line linux list lists loop mouse mysql newb number numbers output panel parsing path port prime print program programming projects py2exe pygame pyqt python queue random rational recursion recursive screensaverloopinactive scrolledtext server ssh stamp statictext string strings sudokusolver table terminal text thread threading time tkinter tlapse tuple tutorial type ubuntu unicode url urllib urllib2 variable whileloop windows write wxpython






