i'm learning BeautifulSoup and i encountered this
from bs4 import BeautifulSoup
import urllib2
url = "https://en.wikipedia.org/wiki/Katy_Perry"
open_url = urllib2.urlopen(url)
read = open_url.read()
print(read)
This prints the html code of the page. But how can we use read() here ? Its a FileIO function and should be used along with the file object. but the variable "open_url" here isn't a file object.
print(type(open_url))
output:
<type 'instance'>
Obviously "open_url" isn't a file object, So what made it possible to bind read() to "open_url" ?