如何解决Selenium网络驱动程序中循环不正确的问题



我是编码新手,正在尝试从谷歌地图中抓取数据。我在网上找到了一个代码,并试图在Jupyter上运行它,但在其中一个函数中不断收到continue not properly in loop错误消息。(据我所知(这在理论上似乎很好,但就是不起作用。

def scrape(self, url):
try:
self.driver.get(url)
except Exception as e:
self.driver.quit()
continue
time.sleep(10)
self.click_open_close_time()
self.get_location_data()
self.get_location_open_close_time()
self.get_popular_times()
if(self.click_all_reviews_button()==False):
continue
time.sleep(5)
self.scroll_the_page()
self.expand_all_reviews()
self.get_reviews_data()
self.driver.quit()
return(self.location_data)

continue只允许在forwhile循环中使用。因此CCD_ 4。

您可以在Python文档中阅读更多关于continue语句的信息:链接

最新更新