2021年4月28日星期三

How to get rid of block while scraping with Selenium

I'm trying to scrape a website with Selenium, but I think it's blocking this access in many ways.

The error message shown is: "selenium.common.exceptions.NoSuchWindowException: Message: Browsing context has been discarded" but sometimes is shown an error saying that time for loading page had expired

Furthermore, Firefox is consuming a huge percent of CPU and Memory when loading this page.

I've already tried to change user-agent, or run it headlessly, but no results.

Below is the code:

from selenium import webdriver  browser = webdriver.Firefox()  browser.get('https://www.bet365.com/#/HO/')  matches = browser.find_elements_by_class_name('him-Fixture')  browser.quit()  

Any tips to bypass it ?

https://stackoverflow.com/questions/67309778/how-to-get-rid-of-block-while-scraping-with-selenium April 29, 2021 at 09:10AM

没有评论:

发表评论