python-3.x - 在 if 语句中查找多个单词或字符串
问题描述
我正在使用 Python 和 Beautiful Soup 4 从网站获取一些文本。我正在使用for 循环说:“仅当返回的文本不包含单词lorem时才打印文本”
我的问题是,除了多个单词,我怎么能做同样的事情?例如lorem、ipsum和dolor。
这是我尝试过的,我不确定如何继续:
for title in soup.select('.panel-heading h3 a'):
if 'lorem' not in title.text:
print(title.text, '-->', title.get('href'))
解决方案
推荐阅读
- python - 如何使用 Selenium 从 Trip Advisor 中抓取数据?- Python
- javascript - 在Javascript中访问模块类中的父方法
- xamarin.ios - Xamarin:捆绑签名的错误证书
- android - 如何刷新/重新加载具有 viewpager2 和 FragmentStateAdapter(fragmentActivity) 的片段
- javascript - DeprecationWarning: Buffer() 当我尝试在可视代码上安装扩展时。请问我该如何解决这个问题
- postgresql - Ktor 无法在 Postgres 中创建表
- snowflake-cloud-data-platform - 是否有任何内置函数或快速方法来获取存储过程或函数中使用的底层对象名称?
- angular - TypeError:无法设置未定义的属性
- java - Spring Data JPA(Spring Boot 2)中的多个表连接
- javascript - 错误 [ERR_STREAM_WRITE_AFTER_END]:结束后写入,http 服务器 node.js