1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 【Python网络爬虫】Python网络爬虫案例:知乎Live

【Python网络爬虫】Python网络爬虫案例:知乎Live

时间:2023-04-26 05:30:49

相关推荐

【Python网络爬虫】Python网络爬虫案例:知乎Live

Python网络爬虫案例:知乎Live

涉及的技术包括以下3种:

爬取网页:解析Ajax动态加载地址解析网页:提取JSON数据存储数据:存储至MongoDB数据库

1.项目描述

知乎Live的URL为:/lives

首先爬取Live的第一页:

#!/usr/bin/env python# -*- coding: utf-8 -*-"""@File : GetLive.py@Author: Xinzhe.Pang@Date : /7/18 22:32@Desc : """import requestsdef scrapy(link):headers = {User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36}r = requests.get(link, headers=headers)return (r.text)link = "/lives/homefeed?includes=live"html = scrapy(link)print(html)

除了首页,我们还尝试获取其他页的Live信息。首先,尝试是

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。