Spider类的一些自定制

# Spider类 自定义  起始解析器
 def start_requests(self):
        for url in self.start_urls:
            yield Request(url=url,callback=self.myparse)

# 起始会先经过这个视图函数返回一个 列表或者 一个生成器
yield Request(url=page_url, callback=self.parse)  #指定解析函数

 parse函数的参数之response

# print(response.request)  # 将请求对象也封装在了response中
# print(response.url)   #  请求的url
# print(response.headers)  # 响应的头
# print(response.headers['Set-Cookie'])  # 原始cookies


['_auto_detect_fun', '_body', '_body_declared_encoding', '_body_inferred
_encoding', '_cached_benc', '_cached_selector', '_cached_ubody', '_declared_encoding', '_encoding', '_get_body', '_get_url', '_headers_encoding', '_se
t_body', '_set_url', '_url', 'body', 'body_as_unicode', 'copy', 'css', 'encoding', 'flags', 'follow', 'headers', 'meta', 'replace', 'request', 'select
or', 'status', 'text', 'url', 'urljoin', 'xpath']
参数

相关文章:

  • 2021-05-19
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2021-11-16
  • 2021-12-21
  • 2021-11-01
猜你喜欢
  • 2021-06-22
  • 2022-02-21
  • 2021-07-17
  • 2021-07-15
  • 2021-09-26
  • 2022-12-23
  • 2021-09-09
相关资源
相似解决方案