def get_download_url(self, detail_page_driver): download_url = None try: ele = detail_page_driver.find_element_by_xpath(self.DOWNLOAD_URL) except selenium_exception.NoSuchElementException as e: try: detail_page_driver.refresh() except selenium_exception.TimeoutException as e: pass try: ele = detail_page_driver.find_element_by_xpath(self.DOWNLOAD_URL) except selenium_exception.NoSuchElementException as e: return download_url return util.href2url(self.SOURCE, ele.get_attribute('href'), util.get_current_url(detail_page_driver))
def get_detail_urls(self, list_page_driver): detail_urls = [] eles = list_page_driver.find_elements_by_xpath(self.DETAIL_URLS) if len(eles) == 0: try: list_page_driver.refresh() except selenium_exception.TimeoutException as e: pass eles = list_page_driver.find_elements_by_xpath(self.DETAIL_URLS) for ele in eles: detail_url = util.href2url(self.SOURCE, ele.get_attribute('href'), util.get_current_url(list_page_driver)) if detail_url: detail_urls.append(detail_url) return detail_urls
def get_download_url(self,detail_page_driver): time.sleep(1.5) download_url = None try: ele = detail_page_driver.find_element_by_xpath(self.DOWNLOAD_URL) except selenium_exception.NoSuchElementException as e: try: detail_page_driver.refresh() except selenium_exception.TimeoutException as e: pass try: ele = detail_page_driver.find_element_by_xpath(self.DOWNLOAD_URL) except selenium_exception.NoSuchElementException as e: return download_url return util.href2url(self.SOURCE,ele.get_attribute('href'),util.get_current_url(detail_page_driver))