python - For Loop 没有遍历所有数据
问题描述
我正在尝试遍历从网站获得的一些文本,但循环中的 if 语句没有跳过我不需要的内容,另一方面,我需要的文本没有被循环遍历和打印.
for i in range(14):
posting = driver.find_elements_by_xpath('//div[contains(@class,"slider_container")][1]')
for value in posting:
values= (value.text)
#cleaning text
number= range(31)
text=[]
for i in values.split():
if i == 'new':
continue
if i == 'Today·More...':
continue
if i == 'Easily apply':
continue
if i == 'Just posted·More...':
continue
if i == 'Just posted':
continue
if i == 'Responsive employer':
continue
for m in number:
date = str(m) + 'days ago·More...'
if i == date:
continue
for m in number:
date = str(m) + 'days ago'
if i == date:
continue
text.append(i)
print (text)
解决方案
推荐阅读
- c# - 显示下一个作业执行预定时间
- python - Python 代码语法在数据块中不起作用
- r - 在 igraph(R 包)中反转有向图(转置图)中的边
- python - 这个python包在pip安装时如何执行download.sh文件?
- android - 如何将谷歌地图键限制为cordova android
- node.js - 如何使用 Mocha/Chai 检查文件类型?
- bash - 如何使用 awk 在每个模式之后进行多次匹配并打印不同数量的行
- view - (莲花笔记)视图可以设置条件(例如:公式)共享吗?
- c++ - 是否可以为非结构(尤其是数字)类型定义类型转换运算符?
- javascript - 在浏览器中更改背景而不影响其余部分