From 1851675a8e84d011ff446e763c68ed815545fa36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E8=8B=B1=E5=81=A5?= Date: Tue, 26 Mar 2019 17:09:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9E=84=E5=BB=BA=E8=B4=B4=E5=90=A7=E7=88=AC?= =?UTF-8?q?=E8=99=AB=E7=9B=AE=E5=BD=95=E7=BB=93=E6=9E=84-=E6=B3=A8?= =?UTF-8?q?=E9=87=8A(=E5=B8=A6=E6=9C=89=E6=96=87=E6=A1=A3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tieba/tieba_spider.py | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tieba/tieba_spider.py diff --git a/tieba/tieba_spider.py b/tieba/tieba_spider.py new file mode 100644 index 0000000..8215091 --- /dev/null +++ b/tieba/tieba_spider.py @@ -0,0 +1,58 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +""" +info: +author:CriseLYJ +github:https://github.com/CriseLYJ/ +update_time:2019-3-6 +""" + +""" +请求URL分析 https://tieba.baidu.com/f?kw=魔兽世界&ie=utf-8&pn=50 +请求方式分析 GET +请求参数分析 pn每页50发生变化,其他参数固定不变 +请求头分析 只需要添加User-Agent +""" + +# 代码实现流程 +# 1. 实现面向对象构建爬虫对象 +# 2. 爬虫流程四步骤 +# 2.1 获取url列表 +# 2.2 发送请求获取响应 +# 2.3 从响应中提取数据 +# 2.4 保存数据 + +import requests + + +class TieBaSpier(): + + def __init__(self): + # 初始化 + pass + + def get_url_list(self): + """获取url列表""" + pass + + def get_content(self): + """发送请求获取响应内容""" + pass + + def get_items(self): + """从响应中提取数据""" + pass + + def save_items(self): + """保存数据""" + pass + + def run(self): + """运行程序""" + pass + + +if __name__ == '__main__': + spider = TieBaSpier() + spider.run()