嗨,我正在尝试使用selenium抓取一个网站,有时网站会阻止我的ip进行抓取,并出现一条弹出消息
我想做的是,每当弹出消息出现时,它就会在我的终端上显示一条警告,我的代码就是这样得到结果的
blo = driver.find_element_by_xpath('/html/body/div[2]/div/div/div[1]/h3')
if blo:
print('ip blocked')
else:
print('eroor')
但它不工作,我只是得到一个空白屏幕,我如何才能解决这个问题
元素的HTML:
<h3 class="modal-title">Notifications</h3>
<div class="alert alert-warning">Sorry, you have exceeded the maximum number of queries allowed per day. If you believe you have reached this message in error, please contact our support team.</div>
验证弹出消息是否存在,您必须为
visibility_of_element_located()
导入WebDriverWait,并且您可以使用以下任一Locator Strategies:使用
CSS_SELECTOR
:使用
XPATH
:相关问题 更多 >
编程相关推荐