Python Forum
urllib is not a package traceback
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
urllib is not a package traceback
#4
Also Requests has taken over what urllib dos in a better way,i have not used urllib in many year,other than sometime help on forum users that use urllib.
Also loop over online .txt like this,you may get new line in wrong place.
import requests

fhand = requests.get('https://www.py4e.com/code/romeo.txt')
for line in fhand:
    print(line.decode().strip())
Output:
But soft what light through yonder window breaks It is the east and Juliet is the sun Arise fair sun and kill the envious moon W ho is already sick and pale with grief
Just do this.
import requests

fhand = requests.get('https://www.py4e.com/code/romeo.txt')
print(fhand.text.strip())
Output:
But soft what light through yonder window breaks It is the east and Juliet is the sun Arise fair sun and kill the envious moon Who is already sick and pale with grief
Reply


Messages In This Thread
urllib is not a package traceback - by cc26 - Aug-28-2020, 04:13 AM
RE: urllib is not a package traceback - by Larz60+ - Aug-28-2020, 04:22 AM
RE: urllib is not a package traceback - by snippsat - Aug-28-2020, 09:34 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  urllib can't find "parse" rjdegraff42 6 2,341 Jul-24-2023, 05:28 PM
Last Post: deanhystad
  Help with urllib.request Brian177 2 2,907 Apr-21-2021, 01:58 PM
Last Post: Brian177
  urllib.request ericmt123 2 2,490 Dec-21-2020, 06:53 PM
Last Post: Larz60+
  urllib request error 404 Coco 2 4,444 May-11-2019, 02:47 PM
Last Post: Larz60+
  KeyError urllib DavidFernandez 4 3,617 Nov-21-2018, 08:34 PM
Last Post: DavidFernandez
  URLLIB.REQUEST Not Working hallofriends 1 6,423 Sep-18-2017, 05:00 PM
Last Post: Larz60+
  how to loop data in urllib? pythonlover 4 7,802 Jan-18-2017, 06:53 PM
Last Post: pythonlover

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020