Using python code to get descriptions of books from Goodreads, however my code doesn't allow me to sign in before starting the actual search, I need to obviously add code to do the signin with my username and pw THEN execute the search.
def fetch_description_genre_and_date_from_goodreads(self, book_author, book_title):
"""Fetch book description from Goodreads."""
self.driver.get('http://goodreads.com/search?query=' + urllib.parse.quote_plus('{} {}'.format(book_author, book_title)))
genre = None
publish_date = None
try:
self.driver.find_elements_by_class_name('bookTitle')[0].click()
try:
WebDriverWait(self.driver, 5).until(
EC.presence_of_element_located((By.CLASS_NAME, 'bookPageGenreLink')))
genre = self.driver.find_element_by_class_name('bookPageGenreLink').text
except TimeoutException:
pass
try:
WebDriverWait(self.driver, 5).until(
EC.presence_of_element_located((By.XPATH, "//div[@id='details']/div[2]")))
publish_date = self.driver.find_element_by_xpath("//div[@id='details']/div[2]").text.split('by')[0].rstrip()
if not 'published' in publish_date.lower():
publish_date = None
except TimeoutException:
pass
long_description = False
WebDriverWait(self.driver, 5).until(
EC.presence_of_element_located((By.ID, 'description')))
for anchor_tag in self.driver.find_element_by_id('description').find_elements_by_tag_name('a'):
if anchor_tag.text == '...more':
anchor_tag.click()
long_description = True
break
return (self.driver.find_elements_by_xpath("//span[starts-with(@id,'freeText')]")[1].text, genre, publish_date)\
if long_description else (self.driver.find_elements_by_xpath("//span[starts-with(@id,'freeText')]")[0].text, genre, publish_date)
except (IndexError, TimeoutException):
return None, genre, publish_date
What happens now is I get the popup for sign in first and the error:
Message: unknown error: Element <a class="bookTitle" itemprop="url" href="/book/show/41880080-all-that-you-leave-behind?from_search=true">...</a> is not clickable at point (214, 326). Other element would receive the click: <div class="loginModal__popUpBook" data-reactid=".2z3blpsmww.0.1.2"></div>
Please can someone perhaps assist me?