首页 > 解决方案 > 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)

标签: pythonseleniumloopsif-statementweb-scraping

解决方案


推荐阅读