mirror of
				https://github.com/serega404/MetricAliexpressExchangeRate.git
				synced 2025-10-31 01:30:37 +03:00 
			
		
		
		
	Update for new design
This commit is contained in:
		
							
								
								
									
										13
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								main.py
									
									
									
									
									
								
							| @@ -20,7 +20,7 @@ if (site.status_code != 200): | |||||||
|  |  | ||||||
| soup = BeautifulSoup(site.text, "html.parser") | soup = BeautifulSoup(site.text, "html.parser") | ||||||
|  |  | ||||||
| for tag in soup.find_all("span", class_="product-price-current"): | for tag in soup.find_all("div", class_="snow-price_SnowPrice__mainS__ugww0l"): | ||||||
|     KursAli = (''.join(x for x in tag.text if (x.isdigit() or x == ','))).replace(',','.') |     KursAli = (''.join(x for x in tag.text if (x.isdigit() or x == ','))).replace(',','.') | ||||||
|      |      | ||||||
| print("Курс Ali: " + KursAli) | print("Курс Ali: " + KursAli) | ||||||
| @@ -36,6 +36,8 @@ if (site.status_code != 200): | |||||||
| KursCBRF = str(json.loads(site.text)["Valute"]["USD"]["Value"]) | KursCBRF = str(json.loads(site.text)["Valute"]["USD"]["Value"]) | ||||||
| print("Курс ЦБ РФ: " + KursCBRF) | print("Курс ЦБ РФ: " + KursCBRF) | ||||||
|  |  | ||||||
|  | print("Разница Ali и CBRF", round(max(float(KursAli), float(KursCBRF)) - min(float(KursAli), float(KursCBRF)), 2)) | ||||||
|  |  | ||||||
| # Send metrics ↓ | # Send metrics ↓ | ||||||
|  |  | ||||||
| url = MetricServerURL + 'api/v1/import/csv?format=1:label:source,2:metric:exchange_usd_rub' | url = MetricServerURL + 'api/v1/import/csv?format=1:label:source,2:metric:exchange_usd_rub' | ||||||
| @@ -52,4 +54,11 @@ if KursAli != '': | |||||||
|     if (x.status_code != 200 and x.status_code != 204): |     if (x.status_code != 200 and x.status_code != 204): | ||||||
|         print("Не удалось отправить метрику: " + str(x.status_code)) |         print("Не удалось отправить метрику: " + str(x.status_code)) | ||||||
| else: | else: | ||||||
|     print("Курс Али пуст") |     print("Курс Али пуст") | ||||||
|  |  | ||||||
|  | if KursCBRF != '' and KursAli != '': | ||||||
|  |     x = requests.post(url, "Diff Ali CBRF," + str(round(max(float(KursAli), float(KursCBRF)) - min(float(KursAli), float(KursCBRF)), 2))) | ||||||
|  |     if (x.status_code != 200 and x.status_code != 204): | ||||||
|  |         print("Не удалось отправить метрику: " + str(x.status_code)) | ||||||
|  | else: | ||||||
|  |     print("Один из курсов пуст") | ||||||
		Reference in New Issue
	
	Block a user