Created
March 4, 2024 04:44
-
-
Save btc100k/4e8cf7d5ef5fdc78b7ec82e72250e578 to your computer and use it in GitHub Desktop.
Parse out 24 hours hash rate & shares from Ocean.xyz
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
from bs4 import BeautifulSoup | |
... | |
# Use Beautiful Soup to parse the HTML | |
soup = BeautifulSoup(html_content, 'html.parser') | |
# Find the table body | |
table_body = soup.find('tbody', id='hashrates-tablerows') | |
# Initialize variables to hold your data | |
hashrate_average = '' | |
accepted_shares = '' | |
# Iterate through each row in the table body | |
for row in table_body.find_all('tr', class_='table-row'): | |
# Check if the first cell contains '24 hrs' | |
if row.find('td', class_='table-cell').text.strip() == '24 hrs': | |
# Extract the hashrate average and accepted shares | |
cells = row.find_all('td', class_='table-cell') | |
hashrate_average = cells[1].text.strip() | |
accepted_shares = cells[2].text.strip() | |
break # Exit the loop since we found the desired row | |
# Display the extracted data | |
print(f"Hashrate Average: {hashrate_average}") | |
print(f"Accepted Shares: {accepted_shares}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment