Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update element selector #6

Merged
merged 2 commits into from
May 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions downloaders/substack_archives_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
class SubstackArchivesDownloader(PDFDownloader):
element_selectors: dict[str, Union[str, tuple]] = {
# elements used in sign-in
'menu_button_css': '.menu-button > svg',
'sign_in_button_css': '.premium',
'get_to_sign_in_page_css': '.desktop-button',
'sign_in_button_css': '.button',
'go_to_login_link_text': 'Log in',
'log_in_with_password_link_text': 'log in with password',
'log_in_with_password_link_text': 'sign in with password',
'username_field_xpath': '//input[@name="email"]',
'password_field_xpath': '//input[@name="password"]',
'submit_button_xpath': '//button[@type="submit"]',
Expand Down Expand Up @@ -69,13 +69,11 @@ def _load_credentials(self, input_username: str, input_password: str):

def _navigate_to_sign_in_page(self):
self._driver.get(self._url_cache.get_archive_url())
menu_button = self._driver.find_element_by_css_selector(self.element_selectors['menu_button_css'])
menu_button.click()
sign_in_button = self._driver.find_element_by_css_selector(self.element_selectors['sign_in_button_css'])
sign_in_url = sign_in_button.get_attribute('href')
sign_in_button = self._driver.find_element_by_css_selector(self.element_selectors['get_to_sign_in_page_css'])
sign_in_button.click()
sign_in_url = self._driver.current_url
substack_subdomain = SubstackArchivesDownloader.extract_substack_subdomain(sign_in_url)
self._url_cache.set_substack_url(substack_subdomain)
self._driver.get(sign_in_url)

def _log_in_using_browser(self):
loaded_successfully = self._wait_for_element_to_load(By.LINK_TEXT,
Expand Down
Binary file modified utilities/chromedriver
Binary file not shown.