I need to extract data from the page: https://acsjournals.onlinelibrary.wiley.com/doi/full/10.3322/caac.21774
My code is:
def fetch_current_article_data(url_article):
options = webdriver.ChromeOptions()
options.add_argument("--headless")
driver = webdriver.Chrome(options=options)
try:
driver.get(url_article)
time.sleep(5) # Allow time for page content to load
article_title_element = WebDriverWait(driver, 20).until(
EC.presence_of_element_located((By.XPATH, '//*[@id="article__content"]/div[2]/div/h1'))
)
article_title = article_title_element.text.strip()
print("Article Title:", article_title)
except Exception as e:
print("An error occurred:", e)
finally:
driver.quit()
fetch_current_article_data("https://acsjournals.onlinelibrary.wiley.com/doi/full/10.3322/caac.21774")
I tried for different selectors, but it looks like the request didn't bring the content. What is my error? Bard and ChatGPT didn't help.