gnula: fix search
This commit is contained in:
@@ -35,14 +35,9 @@ def search(item, texto):
|
|||||||
logger.info()
|
logger.info()
|
||||||
texto = texto.replace(" ", "+")
|
texto = texto.replace(" ", "+")
|
||||||
data = httptools.downloadpage(host).data
|
data = httptools.downloadpage(host).data
|
||||||
url_cse = scrapertools.find_single_match(data, '<form action="([^"]+)"') + "?"
|
cxv = scrapertools.find_single_match(data, 'cx" value="([^"]+)"')
|
||||||
bloque = scrapertools.find_single_match(data, '<form action=.*?</form>').replace('name="q"', "")
|
data = httptools.downloadpage("https://cse.google.es/cse.js?hpg=1&cx=%s" %cxv).data
|
||||||
matches = scrapertools.find_multiple_matches(bloque, 'name="([^"]+).*?value="([^"]+)')
|
cse_token = scrapertools.find_single_match(data, 'cse_token": "([^"]+)"')
|
||||||
post = "q=" + texto + "&"
|
|
||||||
for name, value in matches:
|
|
||||||
post += name + "=" + value + "&"
|
|
||||||
data = httptools.downloadpage(url_cse + post).data
|
|
||||||
cse_token = scrapertools.find_single_match(data, "var cse_token='([^']+)'")
|
|
||||||
item.url = host_search %(texto, cse_token)
|
item.url = host_search %(texto, cse_token)
|
||||||
try:
|
try:
|
||||||
return sub_search(item)
|
return sub_search(item)
|
||||||
@@ -149,7 +144,7 @@ def findvideos(item):
|
|||||||
cuenta = 0
|
cuenta = 0
|
||||||
for datos in bloque:
|
for datos in bloque:
|
||||||
cuenta = cuenta + 1
|
cuenta = cuenta + 1
|
||||||
patron = '<em>(opción %s.*?)</em>' %cuenta
|
patron = '<em>((?:opción|opción) %s.*?)</em>' %cuenta
|
||||||
scrapedopcion = scrapertools.find_single_match(data, patron)
|
scrapedopcion = scrapertools.find_single_match(data, patron)
|
||||||
titulo_opcion = "(" + scrapertools.find_single_match(scrapedopcion, "op.*?, (.*)").upper() + ")"
|
titulo_opcion = "(" + scrapertools.find_single_match(scrapedopcion, "op.*?, (.*)").upper() + ")"
|
||||||
if "TRAILER" in titulo_opcion or titulo_opcion == "()":
|
if "TRAILER" in titulo_opcion or titulo_opcion == "()":
|
||||||
|
|||||||
Reference in New Issue
Block a user