From e939d6746706bfc945bb331f4cb7d650616eb5ad Mon Sep 17 00:00:00 2001 From: pablo Date: Sun, 15 Nov 2020 12:54:17 +0100 Subject: [PATCH] Improvements in listing page URL generation. --- explorer/explorer.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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