Skip to content

Commit

Permalink
changed selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
shaikhsajid1111 committed Sep 18, 2021
1 parent 7e7df85 commit 34ee0a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion twitter_scraper_selenium/driver_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Utilities:
def __wait_until_tweets_appear(driver):
try:
WebDriverWait(driver, 10).until(EC.presence_of_element_located(
(By.CSS_SELECTOR, 'div[data-testid="tweet"]')))
(By.CSS_SELECTOR, '[data-testid="tweet"]')))
except WebDriverException:
print("Tweets did not appear!")

Expand Down
8 changes: 4 additions & 4 deletions twitter_scraper_selenium/element_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ def __method_name(parameters):
@staticmethod
def __fetch_all_tweets(driver):
try:
return driver.find_elements_by_css_selector('div[data-testid="tweet"]')
return driver.find_elements_by_css_selector('[data-testid="tweet"]')
except:
print("Error at method fetch_all_tweets on line no. {} : {}".format(frameinfo.f_lineno, ex))

@staticmethod
def __find_replies(tweet):
try:
replies_element = tweet.find_element_by_css_selector('div[data-testid="reply"]')
replies_element = tweet.find_element_by_css_selector('[data-testid="reply"]')
replies = replies_element.get_attribute("aria-label")
return Scraping_utilities._Scraping_utilities__extract_digits(replies)
except Exception as ex:
Expand All @@ -41,7 +41,7 @@ def __find_replies(tweet):
@staticmethod
def __find_shares(tweet):
try:
shares_element = tweet.find_element_by_css_selector('div[data-testid="retweet"]')
shares_element = tweet.find_element_by_css_selector('[data-testid="retweet"]')
shares = shares_element.get_attribute("aria-label")
return Scraping_utilities._Scraping_utilities__extract_digits(shares)
except Exception as ex:
Expand Down Expand Up @@ -95,7 +95,7 @@ def __find_content(tweet):
@staticmethod
def __find_like(tweet):
try:
like_element = tweet.find_element_by_css_selector('div[data-testid="like"]')
like_element = tweet.find_element_by_css_selector('[data-testid="like"]')
likes = like_element.get_attribute("aria-label")
return Scraping_utilities._Scraping_utilities__extract_digits(likes)
except Exception as ex:
Expand Down

0 comments on commit 34ee0a7

Please sign in to comment.