Python Forum
Cannot open url link using urllib.request
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot open url link using urllib.request
#6
I'd like just to add that this program works without any exception:

import urllib.request

sp_link = r'https://www.kernel.org/doc/readme/drivers-staging-lustre-README.txt'
count = 0
try:
    with urllib.request.urlopen(sp_link) as ip_file:
        for line in ip_file:
            count += 1
    print(count)
except urllib.error.HTTPError as e:
    print(e.reason)
I cannot understand what is the problem. It must be something in the URL address.
Reply


Messages In This Thread
RE: Cannot open url link using urllib.request - by Askic - Oct-25-2020, 04:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  urllib can't find "parse" rjdegraff42 6 2,578 Jul-24-2023, 05:28 PM
Last Post: deanhystad
  I can't open a link with Selenium in Python jao 0 1,449 Jan-30-2022, 04:21 AM
Last Post: jao
  how can I correct the Bad Request error on my curl request tomtom 8 5,267 Oct-03-2021, 06:32 AM
Last Post: tomtom
  Prevent urllib.request from using my local proxy spacedog 0 2,994 Apr-24-2021, 08:55 PM
Last Post: spacedog
  urllib.request.ProxyHandler works with bad proxy spacedog 0 6,056 Apr-24-2021, 08:02 AM
Last Post: spacedog
  Need help with XPath using requests,time,urllib.request and BeautifulSoup spacedog 3 2,960 Apr-24-2021, 02:48 AM
Last Post: bowlofred
  Help with urllib.request Brian177 2 2,964 Apr-21-2021, 01:58 PM
Last Post: Brian177
  urllib.request ericmt123 2 2,537 Dec-21-2020, 06:53 PM
Last Post: Larz60+
  urllib is not a package traceback cc26 3 5,576 Aug-28-2020, 09:34 AM
Last Post: snippsat
  ImportError: cannot import name 'Request' from 'request' abhishek81py 1 4,017 Jun-18-2020, 08:07 AM
Last Post: buran

Forum Jump:

User Panel Messages

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