Rewards2/teepy_rewards2/scrapper.py
def _algoexplorer(self, address, pages=None):
        """
        Scrapes AlgoExplorer.io To fetch transaction data for Address.

        Args:
            - address: desired address for transaction data
            - pages: desired number of pages for response[can be skipped to fetch all pages]
        Returns:
            - List[{}]: A list of transaction data for the given address
        """
        data = []
        self.browser.get(f"{self.web_base_url}{address}")
        # Getting All Rows On the Page
        rows = self.browser.find_elements(by=By.TAG_NAME, value='tr')
        # Getting the Value of The Last Page from The Page
        last_page = self.browser.find_element(By.CLASS_NAME, value="styles_pagination-container__i_fkI")
        last_page = re.sub("[^0123456789\.]", '', last_page.text) # Removing Characters from the LastPage Value (from 'out of 30' to '30')
        curr_page = 1
        next_page_click = self.browser.find_elements(By.CLASS_NAME, 'styles_pagination-btn__vJnM4')[2] # Element To Click For Next Page Navigation
        while curr_page <= int(last_page):
            for row in rows[1:]:
                try:
                    # Fetch All A Tags and All Elements in the Table Row
                    a_tags = row.find_elements(by=By.TAG_NAME, value='a')
                    all_els = row.find_elements(By.XPATH, ".//*")
                    all_elements_count = len(all_els)
                
                    if all_elements_count < 17:
                        # For Algorand Transfer
                        amount = all_els[7].text
                        sender = all_els[9].text
                    else:
                        # For Asset Transfer
                        sender = all_els[10].text
                        amount = a_tags[2].text
                    amount = re.sub("[^0123456789\.]", '', amount)
                    data.append({'from': sender, 'amount': float(amount)})
                except:
                    pass
            if pages:
                # Break The Loop Once Required Page is Reached
                if curr_page == pages:
                    break
            # Click The Nextpage Button and Wait For Spinner To Disappear
            next_page_click.click()
            WebDriverWait(self.browser, 10).until(EC.invisibility_of_element_located((By.CLASS_NAME, 'spinner')))
            curr_page += 1
        self.browser.close()
        return data

        Scrapes AlgoExplorer.io To fetch transaction data for Address.

        Args:
            - address: desired address for transaction data
            - pages: desired number of pages for response[can be skipped to fetch all pages]
        Returns:
            - List[{}]: A list of transaction data for the given address
        
Scrapes AlgoExplorer.io To fetch transaction data for Address.
Scrapes AlgoExplorer . io To fetch transaction data for Address .
def _algoexplorer(self, address, pages=None):
        data = []
        self.browser.get(f"{self.web_base_url}{address}")
        rows = self.browser.find_elements(by=By.TAG_NAME, value='tr')
        last_page = self.browser.find_element(By.CLASS_NAME, value="styles_pagination-container__i_fkI")
        last_page = re.sub("[^0123456789\.]", '', last_page.text) 
        curr_page = 1
        next_page_click = self.browser.find_elements(By.CLASS_NAME, 'styles_pagination-btn__vJnM4')[2] 
        while curr_page <= int(last_page):
            for row in rows[1:]:
                try:
                    a_tags = row.find_elements(by=By.TAG_NAME, value='a')
                    all_els = row.find_elements(By.XPATH, ".//*")
                    all_elements_count = len(all_els)
                    if all_elements_count < 17:
                        amount = all_els[7].text
                        sender = all_els[9].text
                    else:
                        sender = all_els[10].text
                        amount = a_tags[2].text
                    amount = re.sub("[^0123456789\.]", '', amount)
                    data.append({'from': sender, 'amount': float(amount)})
                except:
                    pass
            if pages:
                if curr_page == pages:
                    break
            next_page_click.click()
            WebDriverWait(self.browser, 10).until(EC.invisibility_of_element_located((By.CLASS_NAME, 'spinner')))
            curr_page += 1
        self.browser.close()
        return data
def _algoexplorer ( self , address , pages = None ) : data = [ ] self . browser . get ( f"{self.web_base_url}{address}" ) rows = self . browser . find_elements ( by = By . TAG_NAME , value = 'tr' ) last_page = self . browser . find_element ( By . CLASS_NAME , value = "styles_pagination-container__i_fkI" ) last_page = re . sub ( "[^0123456789\.]" , '' , last_page . text ) curr_page = 1 next_page_click = self . browser . find_elements ( By . CLASS_NAME , 'styles_pagination-btn__vJnM4' ) [ 2 ] while curr_page <= int ( last_page ) : for row in rows [ 1 : ] : try : a_tags = row . find_elements ( by = By . TAG_NAME , value = 'a' ) all_els = row . find_elements ( By . XPATH , ".//*" ) all_elements_count = len ( all_els ) if all_elements_count < 17 : amount = all_els [ 7 ] . text sender = all_els [ 9 ] . text else : sender = all_els [ 10 ] . text amount = a_tags [ 2 ] . text amount = re . sub ( "[^0123456789\.]" , '' , amount ) data . append ( { 'from' : sender , 'amount' : float ( amount ) } ) except : pass if pages : if curr_page == pages : break next_page_click . click ( ) WebDriverWait ( self . browser , 10 ) . until ( EC . invisibility_of_element_located ( ( By . CLASS_NAME , 'spinner' ) ) ) curr_page += 1 self . browser . close ( ) return data
Scrapes AlgoExplorer.io To fetch transaction data for Address.
Scrapes AlgoExplorer . io To fetch transaction data for Address .
"""
        Scrapes AlgoExplorer.io To fetch transaction data for Address.

        Args:
            - address: desired address for transaction data
            - pages: desired number of pages for response[can be skipped to fetch all pages]
        Returns:
            - List[{}]: A list of transaction data for the given address
        """ # Getting All Rows On the Page # Getting the Value of The Last Page from The Page # Removing Characters from the LastPage Value (from 'out of 30' to '30') # Element To Click For Next Page Navigation # Fetch All A Tags and All Elements in the Table Row # For Algorand Transfer # For Asset Transfer # Break The Loop Once Required Page is Reached # Click The Nextpage Button and Wait For Spinner To Disappear
A list of transaction data for the given address
A list of transaction data for the given address
- List[{}]
self
address
pages
- address
desired address for transaction data
desired address for transaction data
- pages
desired number of pages for response[can be skipped to fetch all pages]
desired number of pages for response [ can be skipped to fetch all pages ]