Curso Web Scraping para SEO – Clase 5

Crear lista de enlaces válidos

 

De los enlaces obtenidos anteriormente vamos a descartar algunos que no son páginas web o son usados para búsquedas.

Los enlaces obtenidos los pondremos en una lista

 

# -*- coding: iso-8859-15 -*-

# Proyecto Web Scraping para SEO con Python
# Clase 5: Crear lista de enlaces válidos# webscrap5

import urllib
import re

url = «https://evginformatica.blogspot.com/»

htmluni = urllib.urlopen(url).read()
html=urllib.unquote(htmluni).decode(«utf-8»)busqueda = «href='»+url+«.+?'» 

lista_enlaces = []

enlaces = re.findall(busqueda, html)
for enlace in enlaces:
 
    #quitar href=’ y quitar comilla final
    enlace2 = enlace[6:-1]
   
    #enlaces excluidos
    #/search
    # o que contienen #
    # solo paginas .html
    if enlace2.find(«.html»)>0:
        if enlace2.find(«/search»)<0:
            if enlace2.find(«#»)<0:
                lista_enlaces.append(enlace2)
   

for lenlace in lista_enlaces:
    print lenlace

 

De esta manera ya tenemos los enlaces internos a páginas web de nuestro sitio.

 

pej

https://evginformatica.blogspot.com/p/blog.html

https://evginformatica.blogspot.com/p/cursos-gratis-programacion.html

https://evginformatica.blogspot.com/p/cursoweb.html

https://evginformatica.blogspot.com/p/curso-online-java.html

https://evginformatica.blogspot.com/p/curso-c-avanzado.html

https://evginformatica.blogspot.com/p/curso-programando-con-python.html

https://evginformatica.blogspot.com/p/cursos-online-disponibles-introduccion.html

https://evginformatica.blogspot.com/2018/09/curso-programacion-orientada-objetos_21.html

https://evginformatica.blogspot.com/2018/09/curso-programacion-orientada-objetos_18.html

https://evginformatica.blogspot.com/2018/09/curso-programacion-orientada-objetos.html

https://evginformatica.blogspot.com/2018/10/curso-programando-con-python-clase-5.html

https://evginformatica.blogspot.com/2018/10/curso-programando-con-python-clase-4.html

 

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *