Newbie problem with urllib.request.urlopen

Bernie Connors berniejconnors at gmail.com
Tue Sep 26 14:54:28 EDT 2017


On Tuesday, September 26, 2017 at 12:32:18 PM UTC-3, Bernie Connors wrote:
> Hello,
> 
>       My first post here on C.L.P.  I have only written a few python scripts in 2.7 and now I'm trying my first python 3 script.  Can you tell me why this snippet won't run?
> -----------------------
> from urllib.request import urlopen
> 
> with urlopen('http://geonb.snb.ca/arcgis/rest/services/GeoNB_SNB_Parcels/MapServer/0/query?outSR=4617&f=JSON&where=PID='75385120'') as conn:
>     print(conn)
> -----------------------
> Thanks,
> Bernie.

Peter Otten,

      Yes that seems to work better.  Thanks for the tips.  But I see now that I am getting some http errors when I try to run this code from the Microsoft Azure Notebooks.  Here is the URL to my Note Book:
    https://notebooks.azure.com/n/n31C2DSCOr8/notebooks/URLopen%20Test.ipynb
And here is the error:
    URLError: <urlopen error Tunnel connection failed: 403 Forbidden>

    Does anybody know if something can be done about this with urllib? Or is this completely related to the firewall rules at http://geonb.snb.ca??

Thanks,
Bernie.



More information about the Python-list mailing list