forked from btcmachineordinals/ordinal-machinery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract-sat-value
29 lines (23 loc) · 1.2 KB
/
extract-sat-value
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import csv
import requests
from bs4 import BeautifulSoup
# Read the CSV file and get the inscription IDs from the "Order" column
csv_file = open(r"C:\Users\papo\Documents\Render\BTCMACHINES\operators\BTC_MACHINE3.csv")
csv_reader = csv.reader(csv_file)
next(csv_reader) # Skip the first row
inscription_ids = [row[0] for row in csv_reader]
# Initialize the output CSV file
with open(r"C:\Users\papo\Documents\Render\BTCMACHINES\operators\satvalue.csv", mode="w", newline="") as csv_output_file:
csv_writer = csv.writer(csv_output_file)
csv_writer.writerow(["Inscription ID", "Sat Value"])
# Loop over the inscription IDs and get the SAT value for each one
for inscription_id in inscription_ids:
# Make the request to the URL with the inscription ID
url = f"https://ordinals.com/inscription/{inscription_id}"
response = requests.get(url)
soup = BeautifulSoup(response.content, "html.parser")
# Find the SAT value in the HTML
sat_tag = soup.find("a", href=lambda href: href and "/sat/" in href)
sat_value = sat_tag.text if sat_tag else ""
# Write the results to the output CSV file
csv_writer.writerow([inscription_id, sat_value])