(Nov-07-2023, 11:41 AM)buran Wrote: This is package that is not updated since 2012
I don't think you want to install it.
What python version do you use? Also show your code where you try useurllib
, incl. full traceback you get.
Python version 3.12.0
code used:
import urllib3.request fhand = urllib3.request.urlopen('http://data.pr4e.org/romeo.txt') for line in fhand: print(line.decode().strip())It pulls back the contents for a completely different website:
HTTP/1.1 200 OK
Date: Tue, 07 Nov 2023 12:07:45 GMT
Server: Apache/2.4.18 (Ubuntu)
Last-Modified: Sat, 13 May 2017 11:22:22 GMT
ETag: "1d3-54f6609240717"
Accept-Ranges: bytes
Content-Length: 467
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Connection: close
Content-Type: text/plain
Why should you learn to write programs?
Writing programs (or programming) is a very creative
and rewarding activity. You can write programs
for
many reasons, ranging from making your living to solving
a difficult data analysis problem to having fun to helping
someone else solve a problem. This book assumes that
everyone needs to know how to program, and that once
you know how to program you will figure out what you want
to do with your newfound skills.
Error:Traceback (most recent call last):
File "/Users//Documents/pyfe/ex_12_01/urllib.py", line 1, in <module>
import urllib3.request
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/__init__.py", line 13, in <module>
from . import exceptions
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/exceptions.py", line 7, in <module>
from http.client import IncompleteRead as httplib_IncompleteRead
ModuleNotFoundError: No module named 'http.client'; 'http' is not a package
buran write Nov-07-2023, 12:44 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.