【发布时间】:2016-01-04 10:58:35
【问题描述】:
我试图一次浏览一个网站,点击元素next,在HTML 代码中是class="pg-next"。不过,最终我会走到尽头,不会再有next 元素,此时我想停止循环。我有这样的事情:
pg_next_exists = True
while pg_next_exists:
#
# carry out necessary actions
#
if ...: # if the pg-next element can be found
pass
else:
pg_next_exists = False # at which point the while loop stops
如何检查该元素是否仍然存在?
【问题讨论】: