Skip to content

Instantly share code, notes, and snippets.

@natzir
Created October 7, 2019 14:22
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save natzir/64f03d3008185024ee621967085a3efe to your computer and use it in GitHub Desktop.
Save natzir/64f03d3008185024ee621967085a3efe to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@angulo4
Copy link

angulo4 commented Sep 5, 2020

Gracias por el código, funciona muy bien en Jupyter.

Thanks, just one problem (I'm not so good with Python), on block [6]:

doc = nlp(textp) # <-- on this line of code

I'm getting this TypError:
"TypeError: Argument 'string' has incorrect type (expected str, got list)"
Don't know what to do.
Thanks
Cheers
Mario

@natzir
Copy link
Author

natzir commented Sep 7, 2020

@angulo4 mira a ver si lo que tienes en "textp" es un string, no sea que algún carácter del texto a analizar lo haya roto.

@angulo4
Copy link

angulo4 commented Sep 7, 2020

Solucionado!
Buscando en Google, encontré una posible solución;

textp = " ".join(text) # codigo original

Lo he cambiado por:
textp = " ".join(str(elem) for elem in text) # codigo modificado

Ahora funciona el resto del código.

Muchas gracias @natzir

Mario

@natzir
Copy link
Author

natzir commented Sep 7, 2020

@angulo4 grande!

@angulo4
Copy link

angulo4 commented Oct 1, 2020

Another update,
Utilizando tu código hoy (lo uso muy a menudo, antes de comenzar con SEMrush y otros), me daba "None" en las descripciones. Revisando el código de los resultados de Google, he visto que en:
description = r.find('span', attrs={'class': 'st'})
'class' ha cambiado de 'st' a 'aCOpRe'

He actualizado esa línea a:
description = r.find('span', attrs={'class': 'aCOpRe'})
y ahora me esta funcionando.
La pregunta, sabes si Google cambia las 'class' a menudo?, o no te había pasado antes?

Gracias y saludos

@natzir
Copy link
Author

natzir commented Oct 1, 2020

pasa muy a menudo @angulo4

@angulo4
Copy link

angulo4 commented Oct 1, 2020

Pues nada, gracias y lo iremos actualizando y comentando @natzir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment