Kez323
Posts: 4
Joined: Sat Sep 26, 2015 11:46 pm

read from URL

Thu Oct 01, 2015 3:05 pm

Hey all!

I'm trying to get this script to get text from a local webpage. The page will return a number which I then want python to print out. Sounds fairly easy! but I'm getting errors and I don't know why..

Heres my code:

Code: Select all

import urllib

url = "http://localhost/pi/green.php/"
response = urllib.urlopen(url)
data = response.read()
print data

The error im getting is this:

[Errno 97] Address family not supported by protocol

Thanks!!

User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Re: read from URL

Thu Oct 01, 2015 4:47 pm

Not in a position to test this but get rid of the forward slash at the end of the URL ie.

Code: Select all

url = "http://localhost/pi/green.php"
Dave.
Apple say... Monkey do !!

hal8000
Posts: 190
Joined: Fri Oct 04, 2013 5:22 pm

Re: read from URL

Thu Oct 01, 2015 8:08 pm

Your script works ok for me using this URL:

http://php.net/manual/en/tutorial.php/

So the problem is now the contents of your green.php
page,
There'a lot of matches on google for errorno97
including IMAP servers, hostname addresses
and so on. Link below may help

https://github.com/liftoff/GateOne/issues/242

Return to “Python”