Created
October 13, 2022 09:48
-
-
Save kotakagi0914/623ddd37608f711f52e49c1c7fa4a7d4 to your computer and use it in GitHub Desktop.
git diff result for scrape_age_and_bio.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/tinderbotz/helpers/geomatch_helper.py b/tinderbotz/helpers/geomatch_helper.py | |
| index e6246c3..9261434 100644 | |
| --- a/tinderbotz/helpers/geomatch_helper.py | |
| +++ b/tinderbotz/helpers/geomatch_helper.py | |
| @@ -276,9 +276,9 @@ class GeomatchHelper: | |
| try: | |
| xpath = f'{content}/div/div[1]/div/main/div[1]/div/div/div[1]/div[1]/div/div[2]/div[2]/div' | |
| - bio = self.browser.find_element(By.XPATH, xpath).text | |
| - if 'recent instagram photos' in bio.lower(): | |
| - bio = None | |
| + bio_org = self.browser.find_element(By.XPATH, xpath).text | |
| + # Convert obtained string to byte codes, remove new line code and convert back to string type | |
| + bio = str.encode(bio_org).replace(b'\n', b' ').decode() | |
| except Exception as e: | |
| pass | |
| diff --git a/tinderbotz/helpers/preferences_helper.py b/tinderbotz/helpers/preferences_helper.py | |
| index a3203f5..f06ca64 100644 | |
| --- a/tinderbotz/helpers/preferences_helper.py | |
| +++ b/tinderbotz/helpers/preferences_helper.py | |
| @@ -34,15 +34,13 @@ class PreferencesHelper: | |
| else: | |
| final_percentage = (km / 160) * 100 | |
| - possible_xpaths = ['//*[@aria-label="Maximum distance in kilometres"]', | |
| - '//*[@aria-label="Maximum distance in kilometers"]', | |
| - '//*[@aria-label="Maximum distance in miles"]'] | |
| + possible_xpaths = ['button[data-testid="distance-handle"]'] | |
| for xpath in possible_xpaths: | |
| try: | |
| WebDriverWait(self.browser, self.delay).until( | |
| - EC.presence_of_element_located((By.XPATH, xpath))) | |
| - link = self.browser.find_element(By.XPATH, xpath) | |
| + EC.presence_of_element_located((By.CSS_SELECTOR, xpath))) | |
| + link = self.browser.find_element(By.CSS_SELECTOR, xpath) | |
| break | |
| except TimeoutException: | |
| continue | |
| @@ -68,15 +66,15 @@ class PreferencesHelper: | |
| def set_age_range(self, min, max): | |
| # locate elements | |
| - xpath = '//*[@aria-label="Minimum age"]' | |
| + xpath = 'button[data-testid="min-age-handle"]' | |
| WebDriverWait(self.browser, self.delay).until( | |
| - EC.presence_of_element_located((By.XPATH, xpath))) | |
| - btn_minage = self.browser.find_element(By.XPATH, xpath) | |
| + EC.presence_of_element_located((By.CSS_SELECTOR, xpath))) | |
| + btn_minage = self.browser.find_element(By.CSS_SELECTOR, xpath) | |
| - xpath = '//*[@aria-label="Maximum age"]' | |
| + xpath = 'button[data-testid="max-age-handle"]' | |
| WebDriverWait(self.browser, self.delay).until( | |
| - EC.presence_of_element_located((By.XPATH, xpath))) | |
| - btn_maxage = self.browser.find_element(By.XPATH, xpath) | |
| + EC.presence_of_element_located((By.CSS_SELECTOR, xpath))) | |
| + btn_maxage = self.browser.find_element(By.CSS_SELECTOR, xpath) | |
| min_age_tinder = int(btn_maxage.get_attribute('aria-valuemin')) | |
| max_age_tinder = int(btn_maxage.get_attribute('aria-valuemax')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment