今天学完了爬虫呦
代码如下:
import requests
# 要爬取的网址
url = ''
# =======发送请求获取响应=======
r = requests.get(url=url)
# =======打印状态码=======
print('状态码:', r.status_code )
# =======打印响应内容=======
print('响应内容字符串:', r.text )
# =======保存html文件=======
filename='sight.html'
f=open(filename,'w',encoding='utf-8')
f.write(r.text)
f.close()
print('保存成功')
新手上路勿喷....
可能有错呢,自学字写
python | sklearn |
python | py-game |
ptthon | requests |
确实有点难呢................................................................................
标签:python,text,爬虫,filename,码子,html,url,print,requests From: https://blog.csdn.net/uuwxl/article/details/141087391