python爬取知乎的网站内容
2024-08-28 03:45:14
#获取知乎的网站内容
import requests #数据请求模块 第三方模块 pip install requests
import re #正则表达式
#网页head头
heads = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36'
}
def get_response(html_url):
response = requests.get(url=html_url, headers=heads)
return response url= 'https://zhuanlan.zhihu.com/p/435694901'
response_new = get_response(html_url=url)
print(response_new.text)
#<p data-pid="R1eByHKC">100. 如果你拥有一种超能力,你会用它去做什么</p>
html_data = re.findall('<p data-pid="\w+">(.*?)</p>', response_new.text)
print(html_data) for url in html_data:
print(url)
最新文章
- Ubuntu(Linux系统)虚拟机工具vmtools详细说明
- 最短路(代码来源于kuangbin和百度)
- SeaJS入门篇一 怎么使用query
- Maven的依赖和传递性质
- JavaWeb chapter10 JavaWeb开发模式
- Java基础--serialVersionUID
- Atitit 常见的树形结构 红黑树 &#160;二叉树 &#160;&#160;B树 B+树 &#160;Trie树&#160;attilax理解与总结
- 10大经典CSS3菜单应用欣赏
- 161118、linux(centos) 项目部署阶段相关命令汇总
- Codeforces Round #370 (Div. 2) A B C 水 模拟 贪心
- light oj 1205 - Palindromic Numbers 数位DP
- SQL千万级数据设计和优化
- Redis 命令 - Connection
- 桌面浏览器实现滑动翻页效果(Swiper)
- 《ICSharpCode快速解压缩帮助类》——即粘即用
- javascript location对象
- STL学习:STL库vector、string、set、map用法
- Azure Event Hub 技术研究系列3-Event Hub接收事件
- Spring + Mybatis&#160;集成原理分析
- 21 PagerTabStrip-PagerTitleStrip-viewPager
热门文章
- perl的学习:将分句脚本split-sentences.perl转为python脚本
- [Linux系统]安装时出现Requires: libc.so.6(GLIBC_2.17)(64bit) Requires: systemd Requires: libstdc++.so时解决办法
- Eureka服务剔除下线
- 智能插座的制作(esp01,继电器,arduino)
- 区间(环形)dp
- Visusl Studio使用技巧
- linuxz中压缩解压缩文件
- 关于SQLsever2012报错的一些经验总结
- 【笔记】gitlab+openldap使用memberof筛选登录用户
- EBS关于LPN的API【OM】