Crear un rastreador web con Scrapy en Python
Nicolas Marin Torres
Vamos a ver en este vídeo conceptos de crawling, scraping, y parsing. Si quieres ver un ejemplo de como montar un buscador de dominios expirados con Scrapy te paso el enlace donde he subido el vídeo: https://app.scraping.link/academy
Grupo de Telegram: https://t.me/joinchat/AwFbIh1PuwuEgCk0gVgS4g
Grupo de Discord: https://discord.gg/e9QMRJmNtR
Aquí os dejo el código: import scrapy import gspread
frases_lista = [] gc = gspread.service_account(filename='/home/nicolas/Proyectos/python/sheets/scraping-link-d8434e0ec14a.json')
Abrir por titulo
sh = gc.open("Frases")
Seleccionar primera hoja
worksheet = sh.get_worksheet(0)
class ParascrapearSpider(scrapy.Spider): name = 'parascrapear' allowed_domains = ['parascrapear.com'] start_urls = ['http://parascrapear.com/']
def parse(self, response):
print('Parseando ' + response.url)
next_urls = response.css('a::attr(href)').getall()
for next_url in next_urls:
if next_url is not None:
yield scrapy.Request(response.urljoin(next_url))
frases = response.css('q::text').getall()
for frase in frases:
if frase is not frases_lista:
frases_lista.append(frase)
row_index = len(worksheet.col_values(1)) + 1
worksheet.update('A'+str(row_index), frase)
81912736 Bytes