认识爬虫(1)

可以直接拿来运行

# 防止中文中文出现http协议定义URL中的保留字符,编码成16进制的字符串形式
response = requests.get('https://tieba.baidu.com/f?kw=%E6%B5%81%E6%B5%AA%E6%B1%89')
with open('tieba.html','w+',encoding='utf-8') as f:
    f.write(response.content.decode('utf-8'))

猜你喜欢

转载自blog.csdn.net/fengbansha/article/details/85092043