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'))
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'))
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。