[+] GPU data
This commit is contained in:
+2487
File diff suppressed because it is too large
Load Diff
+13
-10
@@ -9,22 +9,24 @@ import requests
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
|
||||||
class CPU(NamedTuple):
|
class Processor(NamedTuple):
|
||||||
id: int
|
id: str
|
||||||
name: str
|
name: str
|
||||||
passmark: int
|
passmark: int
|
||||||
|
|
||||||
|
|
||||||
def crawl_cpu() -> pd.DataFrame:
|
def crawl_cpu_gpu(cpu: bool) -> pd.DataFrame:
|
||||||
"""
|
"""
|
||||||
Crawl cpu benchmark data
|
Crawl cpu/gpu benchmark data
|
||||||
|
|
||||||
|
:param cpu: True if cpu, False if gpu
|
||||||
"""
|
"""
|
||||||
file = Path("data/cpu.csv")
|
file = Path("data/cpu.csv" if cpu else "data/gpu.csv")
|
||||||
|
|
||||||
if file.exists():
|
if file.exists():
|
||||||
return pd.read_csv(file)
|
return pd.read_csv(file)
|
||||||
|
|
||||||
url = "https://www.cpubenchmark.net/cpu_list.php"
|
url = "https://www.cpubenchmark.net/cpu_list.php" if cpu else "https://www.videocardbenchmark.net/gpu_list.php"
|
||||||
page = requests.get(url)
|
page = requests.get(url)
|
||||||
bs = BeautifulSoup(page.content, "html.parser")
|
bs = BeautifulSoup(page.content, "html.parser")
|
||||||
|
|
||||||
@@ -36,10 +38,10 @@ def crawl_cpu() -> pd.DataFrame:
|
|||||||
cols = row.findAll("td")
|
cols = row.findAll("td")
|
||||||
if len(cols) == 0:
|
if len(cols) == 0:
|
||||||
continue
|
continue
|
||||||
id = int(row["id"].replace("cpu", ""))
|
id = row["id"]
|
||||||
cpu = cols[0].text.strip()
|
name = cols[0].text.strip()
|
||||||
passmark = int(cols[1].text.strip().replace(",", ""))
|
passmark = int(cols[1].text.strip().replace(",", ""))
|
||||||
cpu_list.append(CPU(id=id, name=cpu, passmark=passmark))
|
cpu_list.append(Processor(id=id, name=name, passmark=passmark))
|
||||||
|
|
||||||
file.parent.mkdir(parents=True, exist_ok=True)
|
file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
df = pd.DataFrame(cpu_list)
|
df = pd.DataFrame(cpu_list)
|
||||||
@@ -49,4 +51,5 @@ def crawl_cpu() -> pd.DataFrame:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
crawl_cpu()
|
crawl_cpu_gpu(True)
|
||||||
|
crawl_cpu_gpu(False)
|
||||||
|
|||||||
Reference in New Issue
Block a user