diff --git a/explorer/explorer.py b/explorer/explorer.py index 43f9eb1..540041c 100644 --- a/explorer/explorer.py +++ b/explorer/explorer.py @@ -7,7 +7,7 @@ import datetime from time import sleep from bs4 import BeautifulSoup import re -from random import randint +from random import randint, choice import mysql.connector from core.mysql_wrapper import get_anunciosdb, get_tasksdb from core.config import monthly_new_ads_target, working_hours @@ -210,7 +210,13 @@ class Explorer: root = "https://www.idealista.com/" type = Explorer.ad_types[str(randint(1, 2))] city = "barcelona" - page_number = str(randint(1, 30)) + page_number = str(randint(1, 45)) + order_string = choice( + [ + "?ordenado-por=fecha-publicacion-asc", + "?ordenado-por=fecha-publicacion-desc", + ] + ) url = ( root + type @@ -222,6 +228,7 @@ class Explorer: + "pagina-" + page_number + ".htm" + + order_string ) return url