38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""
|
|
dump_riaa_rows.py
|
|
Dumps the exact cell contents of all rows in table id='search-award-table' for Cam'ron.
|
|
"""
|
|
|
|
import requests
|
|
from bs4 import BeautifulSoup
|
|
|
|
session = requests.Session()
|
|
session.headers.update({
|
|
"User-Agent": (
|
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
|
|
"AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
"Chrome/124.0.0.0 Safari/537.36"
|
|
),
|
|
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
|
})
|
|
|
|
print("Fetching RIAA search page for Cam'ron...")
|
|
params = {
|
|
"tab_active": "default-award",
|
|
"se": "Cam'ron"
|
|
}
|
|
resp = session.get("https://www.riaa.com/gold-platinum/", params=params, timeout=20)
|
|
|
|
soup = BeautifulSoup(resp.text, "html.parser")
|
|
table = soup.find("table", {"id": "search-award-table"})
|
|
|
|
if not table:
|
|
print("Could not find table id='search-award-table'!")
|
|
else:
|
|
rows = table.find_all("tr")
|
|
print(f"Total rows found in search-award-table: {len(rows)}\n")
|
|
for i, r in enumerate(rows):
|
|
cells = [td.get_text(" ", strip=True) for td in r.find_all(["th", "td"])]
|
|
print(f"--- ROW {i} ---")
|
|
print(f"Raw Cells List: {cells}")
|
|
print(f"Row Full Text : {r.get_text(' | ', strip=True)}\n") |