some refinements
This commit is contained in:
parent
32319e1f25
commit
e53bb63ff8
|
@ -8,6 +8,8 @@ import webbrowser
|
|||
import mysql.connector
|
||||
from datetime import datetime
|
||||
|
||||
cerca = "altura"
|
||||
|
||||
cnx = mysql.connector.connect(
|
||||
user='root', password='1234',
|
||||
host='192.168.1.22', port=33066,
|
||||
|
@ -23,16 +25,16 @@ class Anunci:
|
|||
self.preu = preu_capturat
|
||||
|
||||
def te_altura(self):
|
||||
regex = ".*.tic(o|\s|\.).*"
|
||||
regex = ".*(À|Á|à|á|a)tic.*"
|
||||
compilador = re.compile(regex, re.IGNORECASE)
|
||||
atico = compilador.match(desc)
|
||||
regex = ".*d.plex.*"
|
||||
atico = compilador.match(titol)
|
||||
regex = ".*(d|D).plex.*"
|
||||
compilador = re.compile(regex, re.IGNORECASE)
|
||||
duplex = compilador.match(desc)
|
||||
duplex = compilador.match(titol)
|
||||
return atico or duplex
|
||||
|
||||
def te_piscina(self):
|
||||
regex = ".*pi(c|s|z)*ina.*"
|
||||
regex = ".*pi(c|s|z|sc)ina.*"
|
||||
compilador = re.compile(regex, re.IGNORECASE)
|
||||
te = compilador.match(desc)
|
||||
return te
|
||||
|
@ -41,6 +43,10 @@ class Anunci:
|
|||
regex = ".*p.r(qu|k)in.*"
|
||||
compilador = re.compile(regex, re.IGNORECASE)
|
||||
te = compilador.match(desc)
|
||||
if te == False:
|
||||
regex = ".*aparca.*"
|
||||
compilador = re.compile(regex, re.IGNORECASE)
|
||||
te = compilador.match(desc)
|
||||
return te
|
||||
|
||||
def te_traster(self):
|
||||
|
@ -50,18 +56,17 @@ class Anunci:
|
|||
return te
|
||||
|
||||
def es_chalet(self):
|
||||
regex = ".*(chalet|casa).*"
|
||||
regex = ".*(C|c)(halet|asa) .*"
|
||||
compilador = re.compile(regex, re.IGNORECASE)
|
||||
te = compilador.match(titol)
|
||||
return te
|
||||
|
||||
|
||||
cerca = "parquing_altura"
|
||||
|
||||
headers = {
|
||||
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"
|
||||
}
|
||||
base_url = "https://www.departiculares.com/alquiler/barcelona&priceMax=1000"
|
||||
base_url = "https://www.departiculares.com/alquiler/barcelona/el-barcelones&priceMax=1200&sizeMin=60"
|
||||
|
||||
def tractar_anunci(anunci):
|
||||
c0 = cnx.cursor()
|
||||
|
@ -106,7 +111,8 @@ while pagina < pagina_horitzo:
|
|||
titol = anunci.titol
|
||||
desc = anunci.descripcio
|
||||
|
||||
if anunci.te_parquing():
|
||||
#if anunci.te_parquing() and anunci.te_piscina():
|
||||
if anunci.te_altura():
|
||||
anuncis_list.append(anunci)
|
||||
|
||||
for anunci_seleccionat in anuncis_list:
|
||||
|
|
|
@ -15,7 +15,9 @@ c1.execute("SELECT url FROM anuncis WHERE actiu=1 AND veure_mes_tard=0")
|
|||
myresult = c1.fetchall()
|
||||
|
||||
for x in myresult:
|
||||
webbrowser.open(x[0])
|
||||
url = x[0]
|
||||
print('opening '+url)
|
||||
webbrowser.open(url)
|
||||
|
||||
c1.close()
|
||||
|
Loading…
Reference in New Issue