![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python爬虫
鹿上的程序媛
平平无奇民工
展开
-
pyhon爬百度贴吧
Python爬百度贴吧 介绍一下大概流程: 获取需要爬取的url —>发请求获取响应 —>保存响应数据 实现逻辑: 1、使用循环生成url列表 2、遍历url列表发送请求,获取响应 3、将响应保存 #coding=utf-8 import requests class TiebaSpider: def __init__(self,tieba_name): self.tieba_name = tieba_name self.url_temp = "http原创 2020-08-22 13:12:52 · 169 阅读 · 1 评论 -
Python爬虫带header报错
Python爬虫带header报错解决方法 不得不说爬虫理论看起来简单,操作起来就报这个错那个错,今天记录一下爬百度贴吧报过的错,以及解决方案。 1.requests.exceptions.InvalidHeader: Invalid return character or leading space in header: User-Agent 这个报错是说request里面带了无效的header,无效的返回字符或者前面的几个字符有问题。 问题发生背景:我的header是直接从fiddler里面复制出来放到原创 2020-08-22 12:53:51 · 2938 阅读 · 2 评论