Slide 1

Slide 1 text

Scrapy Edgar Marca @matiskay Segundo Data Science Meetup Lima

Slide 2

Slide 2 text

Dictionary • Web Scraping: The process of extracting data from the web. • Spider: A piece a software designed to extract links and items from webpages. • Crawl: Visit all the pages of interest on a site using your spider. • Scrapy Cloud: Hosted crawling at scrapinghub.com

Slide 3

Slide 3 text

How to Start • pip install scrapy • scrapy startproject scrapyblog

Slide 4

Slide 4 text

How to start

Slide 5

Slide 5 text

Types of Spiders • Spider — Base class for scrapy spiders. • SitemapSpider — Allows you to crawl a site by discovering the URLs using Sitemaps. • XMLFeedSpider — XMLFeedSpider is designed for parsing XML feeds by iterating through them by a certain node name. • CrawlSpider — It provides a convenient mechanism for following links by defining a set of rules.

Slide 6

Slide 6 text

Selectors • xpath • response.xpath(‘//span[@class=“blue”]/text()’).extract() • css • response.css(‘span.blue::text’).extract()

Slide 7

Slide 7 text

How to deploy to Scrapy Cloud • shub login • shub deploy • shub schedule blogspider

Slide 8

Slide 8 text

Scrapy Workflow • Crear dos proyectos uno de produccion y desarrollo. • project-prod • project-dev • En desarrollo se hace la verificacion de los datos y todas las posibles transformaciones en los datos. • shub permite deployar usando el ultimo commit de la rama.

Slide 9

Slide 9 text

Pages with Javascript • Splash: Splash is a javascript rendering service.

Slide 10

Slide 10 text

Tools for Cleaning data • w3lib • Remove comments, or tags from HTML snippets • extract base url from HTML snippets • translate entites on HTML strings • convert raw HTTP headers to dicts and vice-versa • construct HTTP auth header • converting HTML pages to unicode • sanitize urls (like browsers do) • extract arguments from urls

Slide 11

Slide 11 text

Machine Learning & NLP • NLTK (Natural Language Toolkit) — http:// www.nltk.org/ • Scikit Learn (Machine Learning in Python) — http:// scikit-learn.org/ • Scikit Image (Image Processing in Python) — http:// scikit-image.org/ • Gensim (Topic Modelling for Humans)— http:// radimrehurek.com/gensim/ • TextBlob (Simplified Text Processing) — http:// textblob.readthedocs.org/en/dev/

Slide 12

Slide 12 text

Aplicaciones

Slide 13

Slide 13 text

Manolo Rocks

Slide 14

Slide 14 text

Recomendacion de Productos • Extraer la informacion de los supermercados. • Utilizar esa informacion para recomendar donde comprar los productos basados en la receta que se va preparar.

Slide 15

Slide 15 text

Venta de productos por refencia • Extraer la informacion de sitios de moda. • Utilizar algoritmos para extraer colores y utilizar esa informacion para el buscador. • Crear un sitema ETL.

Slide 16

Slide 16 text

Recomendacion de Trabajos • Extraer la informacion de sitios de trabajo. • Utilizar algoritmos de Procesamiento Natural de Lenguaje para clasificar los trabajos.

Slide 17

Slide 17 text

Preguntas

Slide 18

Slide 18 text

Gracias