0

I have a string result in this string is the URL www.test.com

I know that on www.test.com is an website with the number 4. I will save the number in my programm as an integer.

import urllib
giveTheInt = [urllib.urlopen(url)]

But i receive only:

IOError: [Errno socket error] [Errno 110] Connection timed out.

The wireless it's ok, I have a connection to the internet.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
user1865863
  • 29
  • 1
  • 5

2 Answers2

1

I know this is urllib2, but I saw your post and this worked for me.

#!/usr/bin/env python
import urllib2
response = urllib2.urlopen('http://ron-swanson-quotes.herokuapp.com/v2/quotes')
# print response.info()
data = response.read()
print data
response.close()  # best practice to close the file

Taken from here.

Alex Cory
  • 10,635
  • 10
  • 52
  • 62
0

Is this what you're looking for?

#!/usr/bin/env python
import urllib

url = "http://stackoverflow.com"
fp = urllib.urlopen(url)
data = fp.read()
n = int(data)
giveTheInt = [n]
print(giveTheInt)

You should test that you can ping your whatever.com. If you can't ping it, that may be why you have an error.

coolaj86
  • 74,004
  • 20
  • 105
  • 125