定义一个方法get_page(url),url参数是需要获取网页内容的网址,返回网页的内容。提示(可以了解python的urllib模块)

1 定义一个方法get_page(url),url参数是需要获取网页内容的网址,返回网页的内容。提示(可以了解python的urllib模块)
2 import urllib.request
3 
4 def get_page(url):
5     response = urllib.request.urlopen(url)
6     html = response.read()
7     return html
8 
9 print(get_page(url='https://www.baidu,com'))
原文地址:https://www.cnblogs.com/themost/p/6798678.html