commit e53083482d0d75d3c20492b66befc8382de6ea2a Author: MeexReay Date: Sat Sep 6 15:37:22 2025 +0300 init commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ff9e935 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + +Copyright (C) 2004 Sam Hocevar + +Everyone is permitted to copy and distribute verbatim or modified +copies of this license document, and changing it is allowed as long +as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/main.py b/main.py new file mode 100755 index 0000000..b4c6a6e --- /dev/null +++ b/main.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 + +import requests +from bs4 import BeautifulSoup + +PAGE_URL = "https://technical.city/ru/cpu/best-price-to-performance" + +SORT_FIELD_PRICE = "price" +SORT_FIELD_QUALITY = "performance" + +SORT_ORDER_DES = "down" +SORT_ORDER_ASC = "up" + +USD_PRICE = 81.37 + +def request_page(page_num=1, sort_field=SORT_FIELD_PRICE, sort_order=SORT_ORDER_ASC): + resp = requests.get(PAGE_URL, params={ + "pg": page_num, + "sort_field": sort_field, + "sort_order": sort_order + }) + + page = BeautifulSoup(resp.text, features="lxml") + + for i in page.find_all("tr"): + tds = [ x.text.strip() for x in i.find_all("td") ] + + if len(tds) < 7: + continue + + name = tds[1] + price = float(tds[4].replace("USD", "").strip()) * USD_PRICE + quality = float(tds[5]) + cores = tds[6].split("/")[0].strip() + threads = tds[6].split("/")[1].strip() + + manufacturer = i.find("img", {"class": "item_photo"})["alt"].split()[0] + + yield [ manufacturer, name, price, quality, cores, threads ] + +cpus = [] + +for i in range(1, 50): + print("Fetching page", i, "...", end="\r") + cpus += list(request_page(i)) + +print("fetched all ", end="\r") + +cpus.sort(key=lambda x: x[2] / x[3]) + +for i in cpus: + print(*i)