I have been trying to extract posts from a forum found at this URL: https://www.thestudentroom.co.uk/showthread.php?t=7263973
The body of the text I am trying to extract is under:
<div class="post-content">
Yet I keep getting the following error whether I use get element to search by XPATH or CLASS_NAME:
NoSuchElementException
I have tried the following as well as looking at several of the similar posts on SO but can't find a solution that works for me, any help would be appreciated
options = Options()
options.add_argument("--headless")
options.headless = True
def get_posts(url):
driver = webdriver.Chrome(options = options)
WebDriverWait(driver, 5)
driver.get(url)
# posts = driver.find_element(By.XPATH, '/html/body/div[2]/div/div[6]/div[1]/div[1]/div[6]/div[3]/div[2]/div[2]').text
posts = driver.find_element(By.CLASS_NAME, 'post-content');
return posts
SR_posts = get_posts(url = "https://www.thestudentroom.co.uk/showthread.php?t=7263973")
SR_posts
Edit: added picture to the HTML class 'post-content' that contains the text HTML of webpage
Edit 2: Second picture of inspect element Inspect element of text body
post-contentinto any class. Well, there is nopost-contentanywherepost-contenton that page. Not even after scrolling the page down