32 lines
714 B
Python
32 lines
714 B
Python
import mysql.connector
|
|
from datetime import datetime
|
|
import webbrowser
|
|
|
|
print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
|
|
|
|
# init params
|
|
def getParams():
|
|
with open('params.yml', 'r') as params_file:
|
|
try:
|
|
return yaml.safe_load(params_file)
|
|
except yaml.YAMLError as error:
|
|
print(error)
|
|
|
|
params = getParams()
|
|
|
|
cnx = mysql.connector.connect(
|
|
user=params['db_user'], password=params['db_password'],
|
|
host=params['db_host'], port=params['db_port'],
|
|
database=params['db_name']
|
|
)
|
|
|
|
c1 = cnx.cursor()
|
|
c1.execute("SELECT url FROM anuncis WHERE actiu=1 AND veure_mes_tard=1")
|
|
myresult = c1.fetchall()
|
|
|
|
for x in myresult:
|
|
webbrowser.open(x[0])
|
|
|
|
c1.close()
|
|
|
|
cnx.close() |