In my code i simply want to check the prize of one article in Unieuro online store, a famous store in italy. But even if i used the User-Agent for allow my connection the program works only sometimes, right now i'm trying and it gives me always this error:
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
How to solve this? Please help me, here is the code
from bs4 import BeautifulSoup
import requests
try:
url = 'https://www.unieuro.it/online/Giochi-Playstation-5/The-Last-of-Us-Parte-I-pidSON9405597' #Unieuro
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36'}
pagina = requests.get(url,headers=headers)
soup = BeautifulSoup(pagina.content,'html.parser')
prezzo = soup.find(id='features').get_text()
prezzo = prezzo.split('Iva Inclusa')[0]
if prezzo.count('%'):
prezzo = prezzo.split('%')[-1]
prezzo = prezzo.strip()
prezzo = prezzo[0:7]
print(prezzo) #fine the last Unieuro
# manda email del prezzo scontato
else:
print('Prezzo non scontato fratellì')
# manda email prezzo non scontato (80,99 €) Unieuro
except requests.exceptions.ConnectionError:
print('Errore fratè')