Python Forum
urllib.request.urlopen and proxy
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
urllib.request.urlopen and proxy
#1
Hello guys,
I am learning python. Now I am at stage to use urllib.request.urlopen.
The code from py4e:

import urllib.request, urllib.parse, urllib.error
fhand = urllib.request.urlopen('http://data.pr4e.org/romeo.txt')
for line in fhand:
    print(line.decode().strip())
Scenario 1: No proxy, no VPN = the code works well.

Scenario 2: Proxy and VPN: I am not getting the romeo.txt content. I am getting proxy warning:
Error:
</script> <div id="wrap"> <div class="container"> <div class="row"> <!-- main content --> <div class="col-md-12" id="main-col"> <div class="page-header"> <div style="text-align: center"> <h1>Oops! Your web browser has incurred an unexpected error.</h1> <h1>Please close your browser and try again</h1> </div> </div> <div class="panel-body"> <p class="strong">If this problem persists please review the following support options for further assistance:</p> <div id="list0"> <br> <ol> <li>
However, when entering http://data.pr4e.org/romeo.txt into browser (FF, Chrome)using the same proxy, the content is displayed in webbrowser.

1. Can you advise why the same content is accessible via webrowser with proxy but the same content is not read by simple python script ?
2. Can you advice how to overcome this issue ?

Thank you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Urllib error wintenrod 3 3,628 Sep-14-2020, 06:18 AM
Last Post: wintenrod
  urlopen error newmoon 2 2,064 Apr-18-2020, 12:01 AM
Last Post: Larz60+
  Connectivity issue with urllib ronen1m 7 4,755 Nov-22-2018, 01:03 PM
Last Post: ronen1m

Forum Jump:

User Panel Messages

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