1-practice之Python爬取百度页面

1.获取需求

from urllib import request

2.根据需求,寻找网站

url = 'http://www.baidu.com'

3.将网站数据获取到本地

req = request.Request(url)
response = request.urlopen(req)

4.定位数据

html_bytes = response.read()

5.存储数据

with open('baidu.html','wb') as f:
    f.write(html_byte)

6.返回到'baidu.html'的内容


			        


    
    
	
    
    
    
    
	
	
	
	
	
	
	
	
    
    百度一下,你就知道
















    








    



	
    
    

 

你可能感兴趣的:(1-practice之Python爬取百度页面)