Minori informazioni con log disabilitato
This commit is contained in:
@@ -8,7 +8,7 @@ from platformcode import logger
|
||||
|
||||
|
||||
def get_long_url(short_url):
|
||||
logger.info("short_url = '%s'" % short_url)
|
||||
logger.debug("short_url = '%s'" % short_url)
|
||||
|
||||
data = httptools.downloadpage(short_url).data
|
||||
ysmm = scrapertools.find_single_match(data, "var ysmm = '([^']+)';")
|
||||
|
||||
@@ -17,7 +17,7 @@ from platformcode import logger
|
||||
|
||||
# Obtiene la URL que hay detrás de un enlace a linkbucks
|
||||
def get_long_url(short_url):
|
||||
logger.info("(short_url='%s')" % short_url)
|
||||
logger.debug("(short_url='%s')" % short_url)
|
||||
|
||||
request_headers = []
|
||||
request_headers.append(["User-Agent",
|
||||
@@ -33,17 +33,17 @@ def get_long_url(short_url):
|
||||
while True:
|
||||
for name, value in response_headers:
|
||||
if name == "set-cookie":
|
||||
logger.info("Set-Cookie: " + value)
|
||||
logger.debug("Set-Cookie: " + value)
|
||||
cookie_name = scrapertools.scrapertools.find_single_match(value, '(.*?)\=.*?\;')
|
||||
cookie_value = scrapertools.scrapertools.find_single_match(value, '.*?\=(.*?)\;')
|
||||
request_headers.append(["Cookie", cookie_name + "=" + cookie_value])
|
||||
|
||||
body, response_headers = scrapertools.read_body_and_headers(url, headers=request_headers)
|
||||
logger.info("body=" + body)
|
||||
logger.debug("body=" + body)
|
||||
|
||||
try:
|
||||
location = scrapertools.scrapertools.find_single_match(body, '<textarea.*?class="caja_des">([^<]+)</textarea>')
|
||||
logger.info("location=" + location)
|
||||
logger.debug("location=" + location)
|
||||
break
|
||||
except:
|
||||
n = n + 1
|
||||
|
||||
@@ -38,15 +38,15 @@ servers = get_server_list()
|
||||
|
||||
|
||||
def get_long_urls(data):
|
||||
logger.info()
|
||||
logger.debug()
|
||||
patron = '<a href="http://([^"]+)"'
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
for short_url in matches:
|
||||
if short_url.startswith(tuple(servers)):
|
||||
logger.info(": " + short_url)
|
||||
logger.debug(": " + short_url)
|
||||
longurl_data = httptools.downloadpage(
|
||||
"http://api.longurl.org/v2/expand?url=" + urllib.quote_plus(short_url)).data
|
||||
logger.info(longurl_data)
|
||||
logger.debug(longurl_data)
|
||||
try:
|
||||
long_url = scrapertools.scrapertools.find_single_match(longurl_data, '<long-url><!\[CDATA\[(.*?)\]\]></long-url>')
|
||||
except:
|
||||
|
||||
@@ -5,9 +5,9 @@ from platformcode import logger
|
||||
|
||||
|
||||
def get_long_url(short_url):
|
||||
logger.info("(short_url='%s')" % short_url)
|
||||
logger.debug("(short_url='%s')" % short_url)
|
||||
|
||||
location = scrapertools.get_header_from_response(short_url, header_to_get="location")
|
||||
logger.info("location=" + location)
|
||||
logger.debug("location=" + location)
|
||||
|
||||
return location
|
||||
|
||||
Reference in New Issue
Block a user