I am just trying to fetch data from a live web by using the urllib module, so I wrote a simple example
Here is my code:
import urllib
sock = urllib
For python 3 the correct way should be:
import cv2
import numpy as np
import urllib.request
req = urllib.request.urlopen('http://answers.opencv.org/upfiles/logo_2.png')
arr = np.asarray(bytearray(req.read()), dtype=np.uint8)
img = cv2.imdecode(arr, -1) # 'Load it as it is'
cv2.imshow('image_name', img)
if cv2.waitKey() & 0xff == 27: quit()
Here you can find the documentation related to urllib.request
import requests
import urllib
link = "http://www.somesite.com/details.pl?urn=2344"
f = urllib.request.urlopen(link)
myfile = f.read()
writeFileObj = open('output.xml', 'wb')
writeFileObj.write(myfile)
writeFileObj.close()