python - 使用 python 读取网站上的脚本
问题描述
我目前正在尝试编写一个 python 脚本,当网站更新它的公寓选择时,它会通过邮件通知我。但是,当我使用 Beautiful Soup 时,该站点不会返回项目列表,而是选择所有相关房屋的脚本,而不是所述脚本的结果。我有什么方法可以检索我通常作为用户看到的网站文本的 html 吗?这是我编写的相当简单的代码,以防万一。
html = #somesite
response = requests.get(html)
text = BeautifulSoup(response.text)
text.find_all("script")
解决方案
html = #somesite
response = requests.get(html)
text = BeautifulSoup(response.text)
text.text # returns text in the entire html body, excluding script
推荐阅读
- php - 无法使用 openssl_private_decrypt 解密任何消息
- c# - C# 和深拷贝中的 Elm 架构 (MVU)
- html - 画外音无法从选择下拉列表中发音非英语选项
- sql-server - 如何通过加入另一个表从数据中更新在xml中具有多个相同元素的表中的xml
- cordova - 安装`ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated`后无法构建我的Ionic项目
- python - 相同的命令但不同的结果,cmd和python子进程之间的奇怪行为
- libgdx - LibGDX / Box2D:如何跟踪身体之间的活动联系?
- arrays - 如何在反应中设置动态填充的选择选项的状态?TypeError:this.state.schoolName.map 不是函数
- python - 我想调整图像大小,但显示错误
- mysql - 如何处理 MySQL 错误:从 Oracle 迁移到 MySQL 期间出现 1071?