SlideShare a Scribd company logo
by examples
                       Scraping
                        Alexandre Gomes
Friday, May 20, 2011
http://creativecommons.org/licenses/by-nc/3.0/br/
Friday, May 20, 2011
Primeiros resultados definitivos do Censo 2010:
      população do Brasil é de 190.755.799 pessoas
      O Brasil tem 190.755.799 habitantes. É o que
      constata a Sinopse do Censo Demográfico 2010, que
      contém os primeiros resultados definitivos do XII
      Recenseamento Geral do Brasil... 29/04/2011




                       http://www.ibge.gov.br
Friday, May 20, 2011
Resumo do Censo 2010

Friday, May 20, 2011
Resumo do Censo 2010

Friday, May 20, 2011
Friday, May 20, 2011
Friday, May 20, 2011
Qual a relação entre os índices de
  alfabetização e a proporção feminina?




Friday, May 20, 2011
Exemplo
      mulheres da região               7.859.539
                              =                                 = 0.49
total de pessoas da região        7.859.539 + 8.004.915

  alfabetizados* da região             11.326.492
                              =                                 = 0.89
total de pessoas* da região            12.670.041

                                                    * acima de 10 anos de idade
Friday, May 20, 2011
E nas
      demais
     regiões?
Friday, May 20, 2011
Scraping by
Friday, May 20, 2011
                        Examples
Nokogiri


Friday, May 20, 2011
#1 Acessar a página que
                           contém o dado
                              desejado




Friday, May 20, 2011
teste




Friday, May 20, 2011
teste



  codigo


Friday, May 20, 2011
$ rspec spec/ibge_censo2010_spec.rb:8
Run filtered using {:line_number=>8}

IBGECenso2010
  should open page with "Razão de sexo,
população de homens e mulheres"

Finished in 44.4 seconds
1 example, 0 failures
$


Friday, May 20, 2011
#2 Recuperar o
                       dado desejado




Friday, May 20, 2011
Antes, entenda a
                       estrutura da página




Friday, May 20, 2011
<table>
   <thead>...</thead>
   <tfoot>
     <tr>
       <td>...</td>
       <td>...</td>
       <td>...</td>
       <td>...</td>
                       <td>...</td>
     </tr>
   </tfoot>                           Estude o caminho
   <tbody>...</tbody>                 do dado na árvore
                                            DOM
 </table>
Friday, May 20, 2011
Observe IDs e
                       classes CSS que
                       podem ser úteis.




Friday, May 20, 2011
Friday, May 20, 2011
class="td_numeros"




Friday, May 20, 2011
Friday, May 20, 2011
Friday, May 20, 2011
".td_numeros"


           [

Friday, May 20, 2011
".td_numeros"


           [           0    1          2
                        3    4          5
                        6    7          8
                        9   10         11
                       12   13         14
Friday, May 20, 2011
                       15   16         17
1º dado de que
                               precisamos.
                            (numerador da fórmula)




           [           0           1                 2
                        3           4                 5
                        6           7                 8
                        9          10                11
                       12          13                14
Friday, May 20, 2011
                       15          16                17
2º dado de que
                                     precisamos.
                                    (para o cálculo do
                                 denominador da fórmula)



           [           0    1             2
                        3    4             5
                        6    7             8
                        9   10            11
                       12   13            14
Friday, May 20, 2011
                       15   16            17
mulheres da região N              dados[5]
                                =
 total de pessoas da região N        dados[4] + dados[5]



           [           0        1                2
                        3        4                5
                        6        7                8
                        9       10               11
                       12       13               14
Friday, May 20, 2011
                       15       16               17
teste




Friday, May 20, 2011
code




Friday, May 20, 2011
$ rspec spec

IBGECenso2010
  razao de sexo
    should open page with "Razão de sexo,
população de homens e mulheres"
    should get number of women

Finished in 1.78 seconds
2 examples, 0 failures

Friday, May 20, 2011
teste




Friday, May 20, 2011
code




Friday, May 20, 2011
#3 Recuperar o
                       restante de dados
                           desejados



Friday, May 20, 2011
Friday, May 20, 2011
...
Friday, May 20, 2011
#4 Apresentação
                       Web do scrapping

Friday, May 20, 2011
application.rb




   (...)
Friday, May 20, 2011
application.rb
     (...)




Friday, May 20, 2011
index.erb




(...)

Friday, May 20, 2011
http://datavisualization.ch/tools/13-javascript-libraries-for-visualizations
Friday, May 20, 2011
me    do s
   o c har          na
         ups e s tá
  m ash          ção
        sualiza
     vi
     diferenciada
                                                    de dados

  http://datavisualization.ch/tools/13-javascript-libraries-for-visualizations
Friday, May 20, 2011
#5 Visualização
               (ainda tosca) do
                   scrapping




Friday, May 20, 2011
Friday, May 20, 2011
#6 Visualização
                       diferenciada da
                         informação




Friday, May 20, 2011
Friday, May 20, 2011
                       ?
Agora, a
                         mesma
                          coisa,
                         apenas
                          com
                       Javascript
Friday, May 20, 2011
#1 Acessar a página que
                           contém o dado
                              desejado




Friday, May 20, 2011
test




Friday, May 20, 2011
code




Friday, May 20, 2011
Friday, May 20, 2011
#2 Recuperar o
                       dado desejado




Friday, May 20, 2011
test




Friday, May 20, 2011
code




Friday, May 20, 2011
#3 Recuperar o
                       restante de dados
                           desejados



Friday, May 20, 2011
...
Friday, May 20, 2011
#4 Apresentação
                       Web do scrapping

Friday, May 20, 2011
index.html




Friday, May 20, 2011
index.html




Friday, May 20, 2011
index.html




Friday, May 20, 2011
index.html




Friday, May 20, 2011
index.html




                       (...)
Friday, May 20, 2011
index.html




                       (...)
Friday, May 20, 2011
index.html


        (...)




Friday, May 20, 2011
index.html


        (...)




Friday, May 20, 2011
http://chart.apis.google.com/chart?
  chxt=y&chbh=a&chs=500x300&cht=bvg&chco=A2C180,3D7930
     &chd=t:49,51,51,50,50|89,82,94,95,93
                       &chdl=Women|Literates&chp=0.033
Friday, May 20, 2011
código disponível em...




Friday, May 20, 2011
P&R
Friday, May 20, 2011
http://tinyurl.com/AvaliacaoSOO14




Friday, May 20, 2011
Friday, May 20, 2011

More Related Content

PDF
Estate Jewelry Seo Ranking Report
PDF
Partial rankingreport-3-04-2011
PDF
Search Engine Ranking Report June July 2011
PPTX
The 2012 Elections & The Impact on the US Economy
PDF
Decals window-graphics-rankings
KEY
Aidan E Cybermission Presentation
PDF
Top 20 ranking results 4 6-2011
PDF
Ranking report-february
Estate Jewelry Seo Ranking Report
Partial rankingreport-3-04-2011
Search Engine Ranking Report June July 2011
The 2012 Elections & The Impact on the US Economy
Decals window-graphics-rankings
Aidan E Cybermission Presentation
Top 20 ranking results 4 6-2011
Ranking report-february

Viewers also liked (6)

PDF
Opatrovanie v minikolektive(Bratislava)
ODP
PPS
Eskisehir Hasbahce Evleri
PDF
Vesely Domcek4
ODP
PDF
禅があなたをシンプルにそして楽にする
Opatrovanie v minikolektive(Bratislava)
Eskisehir Hasbahce Evleri
Vesely Domcek4
禅があなたをシンプルにそして楽にする
Ad

More from Alexandre Gomes (20)

PDF
Construção de Software - 1º/2017
PDF
TDDing com Javascript
PDF
Aprendendo a Aprender
PDF
Programação Funcional com Javascript
PDF
UnB/PPCA/CS2016 - Projeto 2
PDF
Javascript do jeito certo
PDF
Construção de Software - 1º/2016
PDF
Plano de Ensino de Tópicos Avançados em Engenharia de Software
PDF
O Pensamento Ágil
PDF
Manifesto 2.0
PDF
Construção de Software - 1º semestre de 2014
PDF
Business Modeling
PDF
Design Thinking
PDF
Manifesto Ágil
PDF
Laboratório de Métodos Ágeis 1/2014 - Apresentação
KEY
Scraping by examples
PDF
OpenData, Web Semântica e afins.
KEY
Javascript do jeito certo
KEY
Javascript orientado a testes
ZIP
Escolhas 2.0
Construção de Software - 1º/2017
TDDing com Javascript
Aprendendo a Aprender
Programação Funcional com Javascript
UnB/PPCA/CS2016 - Projeto 2
Javascript do jeito certo
Construção de Software - 1º/2016
Plano de Ensino de Tópicos Avançados em Engenharia de Software
O Pensamento Ágil
Manifesto 2.0
Construção de Software - 1º semestre de 2014
Business Modeling
Design Thinking
Manifesto Ágil
Laboratório de Métodos Ágeis 1/2014 - Apresentação
Scraping by examples
OpenData, Web Semântica e afins.
Javascript do jeito certo
Javascript orientado a testes
Escolhas 2.0
Ad

Recently uploaded (20)

PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Tartificialntelligence_presentation.pptx
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
1 - Historical Antecedents, Social Consideration.pdf
PPTX
1. Introduction to Computer Programming.pptx
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
A Presentation on Touch Screen Technology
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Getting Started with Data Integration: FME Form 101
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Approach and Philosophy of On baking technology
PPTX
cloud_computing_Infrastucture_as_cloud_p
SOPHOS-XG Firewall Administrator PPT.pptx
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Heart disease approach using modified random forest and particle swarm optimi...
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Building Integrated photovoltaic BIPV_UPV.pdf
Tartificialntelligence_presentation.pptx
Group 1 Presentation -Planning and Decision Making .pptx
1 - Historical Antecedents, Social Consideration.pdf
1. Introduction to Computer Programming.pptx
Enhancing emotion recognition model for a student engagement use case through...
MIND Revenue Release Quarter 2 2025 Press Release
Encapsulation_ Review paper, used for researhc scholars
Assigned Numbers - 2025 - Bluetooth® Document
A Presentation on Touch Screen Technology
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Getting Started with Data Integration: FME Form 101
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
TLE Review Electricity (Electricity).pptx
Approach and Philosophy of On baking technology
cloud_computing_Infrastucture_as_cloud_p

Scraping by examples