李强-第二次作业
这个作业属于哪个课程 | https://edu.cnblogs.com/campus/fzzcxy/ZhichengSoftengineeringPracticeFclass/ |
---|---|
这个作业要求在哪里 | https://edu.cnblogs.com/campus/fzzcxy/ZhichengSoftengineeringPracticeFclass/homework/12532 |
这个作业的目标 | 使用fiddler抓取商品价格并实时监控 |
Github 地址 | https://github.com/hpjojo/212106767pupu |
具体完成思路
我是用fiddler和python进行抓取分析实现的
-
第一步:安装软件了,没什么难度唯一就是记得别安装到c盘(ps:C盘空间太小不好)
-
第二步:打开fiddler,进行设置安装证书
-
第三步:直接打开电脑微信,搜索扑扑小程序,先不急着打开,先清除当前抓到的东西,然后打开小程序,接着选择你要的商品(注意观察fiddler进程变化)url带个pupu那个就是你要商品,你可以右键复制链接浏览打开大概查看json文件确定是你要的商品
-
第四步:打开python,利用request模块进行爬虫,将爬下的数据进行解析筛选出商品信息,
resopnse = requests.get(url, headers=headers1).json()
print(resopnse)
#将json文件进行解析
def pupu(resopnse):
# itme=json.dumps(resopnse)
#
# print(itme)
# time1_str=datetime.datetime.now().strftime('%Y-%m-%d')
name = resopnse['data']['name']
d = resopnse['data']['price']
print(strftime("%Y-%m-%d %H:%M:%S", localtime()))
print(name,d/100)
def func_task():
print('执行任务中...')
#定时器
def func_timer():
func_task()
global timer # 定义全局变量
# 定时器构造函数主要有2个参数,第一个参数为时间,第二个参数为函数名
timer = threading.Timer(10, func_timer) # 10秒调用一次函数
pupu(resopnse)
timer.start() #启用定时器
timer = threading.Timer(1, func_timer)
# timer.start()
# print('定时器启动成功-----')
if __name__ == '__main__':
func_timer()
- 第五步:做一个时间循环,实时监控