{"id":2657,"date":"2010-12-30T14:01:07","date_gmt":"2010-12-30T14:01:07","guid":{"rendered":"http:\/\/osmeusapontamentos.com\/?p=2657"},"modified":"2010-12-30T14:01:07","modified_gmt":"2010-12-30T14:01:07","slug":"scraping-parlamento-pt","status":"publish","type":"post","link":"https:\/\/osmeusapontamentos.com\/index.php\/2010\/12\/30\/scraping-parlamento-pt\/","title":{"rendered":"Scraping parlamento.pt"},"content":{"rendered":"<p>Because <a href=\"http:\/\/lists.hacklaviva.net\/htdig.cgi\/transparencia-porto-hacklaviva.net\/2010-December\/000155.html\">scraping<\/a> is the boring part of exploring data I tried to find the easiest, less time-consuming, yet easy to maintain set of tools to do it.<br \/>\nSince the URLs are (somewhat) well known, I was able to skip the crawler, url discovery part of this projects, I just curl(ed) the page that I wanted and then parsed it to get the information I needed.<\/p>\n<p>Fortunately the <a href=\"http:\/\/www.parlamento.pt\">parlamento.pt<\/a> site is built in such a way that I don&#8217;t have to do the usual regexp or string manipulation magic to get what I want, as all the elements of the page have a unique id that i can reference. I just used a simple xpath expression and I have what I need.<\/p>\n<p>At this point I had the information I needed. All I had to do was save it somewhere. My early experiments were using the\u00a0traditional\u00a0relational database approach (in this case a MySQL database) that I work with everyday. This is not only tedious but also a very closed approach because all I get is another silo with information (a.k.a. table) &#8230; if I want to make it available to users i either have to create database users, make some database interface or API for others to use, or go the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Data_dump\">data dump<\/a> road.<\/p>\n<p>But neverthless it stayed that way a couple of months until I tried <a href=\"http:\/\/couchdb.apache.org\/\">couchdb<\/a>.<br \/>\nThis happened during the <a href=\"http:\/\/www.opendataday.org\/\">hackathon<\/a>. I went to Lisbon to get to know other folks that seemed interested in this opendata thing and these guys (<a href=\"http:\/\/www.twitter.com\/bpedro\">bpedro<\/a>, <a href=\"http:\/\/www.twitter.com\/ruidlopes\">ruidlopes<\/a>, <a href=\"http:\/\/www.twitter.com\/jneves\">jneves<\/a> and others, sorry didn&#8217;t get your name) were really into couchdb so I decided to give a try.<\/p>\n<p>And I think it&#8217;s the best solution so far. What i really like is the &#8220;field&#8221; creation as you go kind of thing, revisions and specially the json output that you get for free. I think it&#8217;s really appropriate for what I&#8217;m doing&#8230; (to be continued)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Because scraping is the boring part of exploring data I tried to find the easiest, less time-consuming, yet easy to maintain set of tools to do it. Since the URLs are (somewhat) well known, I was able to skip the crawler, url discovery part of this projects, I just curl(ed) the page that I wanted [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[181,290,467,592,644],"class_list":["post-2657","post","type-post","status-publish","format-standard","hentry","category-ler-ver-ouvir-passear","tag-dados-publicos","tag-hacklaviva","tag-open-data","tag-scraping","tag-transparencia"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Scraping parlamento.pt - Os Meus Apontamentos<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/osmeusapontamentos.com\/index.php\/2010\/12\/30\/scraping-parlamento-pt\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Scraping parlamento.pt - Os Meus Apontamentos\" \/>\n<meta property=\"og:description\" content=\"Because scraping is the boring part of exploring data I tried to find the easiest, less time-consuming, yet easy to maintain set of tools to do it. Since the URLs are (somewhat) well known, I was able to skip the crawler, url discovery part of this projects, I just curl(ed) the page that I wanted [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/osmeusapontamentos.com\/index.php\/2010\/12\/30\/scraping-parlamento-pt\/\" \/>\n<meta property=\"og:site_name\" content=\"Os Meus Apontamentos\" \/>\n<meta property=\"article:published_time\" content=\"2010-12-30T14:01:07+00:00\" \/>\n<meta name=\"author\" content=\"Vitor Silva\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vitorsilva\" \/>\n<meta name=\"twitter:site\" content=\"@vitorsilva\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vitor Silva\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tempo estimado de leitura\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2010\\\/12\\\/30\\\/scraping-parlamento-pt\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2010\\\/12\\\/30\\\/scraping-parlamento-pt\\\/\"},\"author\":{\"name\":\"Vitor Silva\",\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/#\\\/schema\\\/person\\\/d508df9c3ffc8b4e64a18dbf0ba18dd8\"},\"headline\":\"Scraping parlamento.pt\",\"datePublished\":\"2010-12-30T14:01:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2010\\\/12\\\/30\\\/scraping-parlamento-pt\\\/\"},\"wordCount\":327,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/#\\\/schema\\\/person\\\/d508df9c3ffc8b4e64a18dbf0ba18dd8\"},\"keywords\":[\"dados publicos\",\"hacklaviva\",\"open data\",\"scraping\",\"transpar\u00eancia\"],\"articleSection\":[\"Ler\\\/ Ver\\\/ Ouvir\\\/ Passear\"],\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2010\\\/12\\\/30\\\/scraping-parlamento-pt\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2010\\\/12\\\/30\\\/scraping-parlamento-pt\\\/\",\"url\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2010\\\/12\\\/30\\\/scraping-parlamento-pt\\\/\",\"name\":\"Scraping parlamento.pt - Os Meus Apontamentos\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/#website\"},\"datePublished\":\"2010-12-30T14:01:07+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2010\\\/12\\\/30\\\/scraping-parlamento-pt\\\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2010\\\/12\\\/30\\\/scraping-parlamento-pt\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2010\\\/12\\\/30\\\/scraping-parlamento-pt\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\\\/\\\/osmeusapontamentos.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Scraping parlamento.pt\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/#website\",\"url\":\"https:\\\/\\\/osmeusapontamentos.com\\\/\",\"name\":\"Os Meus Apontamentos\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/#\\\/schema\\\/person\\\/d508df9c3ffc8b4e64a18dbf0ba18dd8\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/osmeusapontamentos.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"pt-PT\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/#\\\/schema\\\/person\\\/d508df9c3ffc8b4e64a18dbf0ba18dd8\",\"name\":\"Vitor Silva\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-PT\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f81f58ad909e8a213ab0a690f6ed65e5c0e0e2274bf35ac49ff31d7988d483ce?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f81f58ad909e8a213ab0a690f6ed65e5c0e0e2274bf35ac49ff31d7988d483ce?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f81f58ad909e8a213ab0a690f6ed65e5c0e0e2274bf35ac49ff31d7988d483ce?s=96&d=mm&r=g\",\"caption\":\"Vitor Silva\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f81f58ad909e8a213ab0a690f6ed65e5c0e0e2274bf35ac49ff31d7988d483ce?s=96&d=mm&r=g\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/vitormrsilva\",\"https:\\\/\\\/x.com\\\/vitorsilva\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Scraping parlamento.pt - Os Meus Apontamentos","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/osmeusapontamentos.com\/index.php\/2010\/12\/30\/scraping-parlamento-pt\/","og_locale":"pt_PT","og_type":"article","og_title":"Scraping parlamento.pt - Os Meus Apontamentos","og_description":"Because scraping is the boring part of exploring data I tried to find the easiest, less time-consuming, yet easy to maintain set of tools to do it. Since the URLs are (somewhat) well known, I was able to skip the crawler, url discovery part of this projects, I just curl(ed) the page that I wanted [&hellip;]","og_url":"https:\/\/osmeusapontamentos.com\/index.php\/2010\/12\/30\/scraping-parlamento-pt\/","og_site_name":"Os Meus Apontamentos","article_published_time":"2010-12-30T14:01:07+00:00","author":"Vitor Silva","twitter_card":"summary_large_image","twitter_creator":"@vitorsilva","twitter_site":"@vitorsilva","twitter_misc":{"Escrito por":"Vitor Silva","Tempo estimado de leitura":"2 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/osmeusapontamentos.com\/index.php\/2010\/12\/30\/scraping-parlamento-pt\/#article","isPartOf":{"@id":"https:\/\/osmeusapontamentos.com\/index.php\/2010\/12\/30\/scraping-parlamento-pt\/"},"author":{"name":"Vitor Silva","@id":"https:\/\/osmeusapontamentos.com\/#\/schema\/person\/d508df9c3ffc8b4e64a18dbf0ba18dd8"},"headline":"Scraping parlamento.pt","datePublished":"2010-12-30T14:01:07+00:00","mainEntityOfPage":{"@id":"https:\/\/osmeusapontamentos.com\/index.php\/2010\/12\/30\/scraping-parlamento-pt\/"},"wordCount":327,"commentCount":3,"publisher":{"@id":"https:\/\/osmeusapontamentos.com\/#\/schema\/person\/d508df9c3ffc8b4e64a18dbf0ba18dd8"},"keywords":["dados publicos","hacklaviva","open data","scraping","transpar\u00eancia"],"articleSection":["Ler\/ Ver\/ Ouvir\/ Passear"],"inLanguage":"pt-PT","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/osmeusapontamentos.com\/index.php\/2010\/12\/30\/scraping-parlamento-pt\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/osmeusapontamentos.com\/index.php\/2010\/12\/30\/scraping-parlamento-pt\/","url":"https:\/\/osmeusapontamentos.com\/index.php\/2010\/12\/30\/scraping-parlamento-pt\/","name":"Scraping parlamento.pt - Os Meus Apontamentos","isPartOf":{"@id":"https:\/\/osmeusapontamentos.com\/#website"},"datePublished":"2010-12-30T14:01:07+00:00","breadcrumb":{"@id":"https:\/\/osmeusapontamentos.com\/index.php\/2010\/12\/30\/scraping-parlamento-pt\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/osmeusapontamentos.com\/index.php\/2010\/12\/30\/scraping-parlamento-pt\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/osmeusapontamentos.com\/index.php\/2010\/12\/30\/scraping-parlamento-pt\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/osmeusapontamentos.com\/"},{"@type":"ListItem","position":2,"name":"Scraping parlamento.pt"}]},{"@type":"WebSite","@id":"https:\/\/osmeusapontamentos.com\/#website","url":"https:\/\/osmeusapontamentos.com\/","name":"Os Meus Apontamentos","description":"","publisher":{"@id":"https:\/\/osmeusapontamentos.com\/#\/schema\/person\/d508df9c3ffc8b4e64a18dbf0ba18dd8"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/osmeusapontamentos.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-PT"},{"@type":["Person","Organization"],"@id":"https:\/\/osmeusapontamentos.com\/#\/schema\/person\/d508df9c3ffc8b4e64a18dbf0ba18dd8","name":"Vitor Silva","image":{"@type":"ImageObject","inLanguage":"pt-PT","@id":"https:\/\/secure.gravatar.com\/avatar\/f81f58ad909e8a213ab0a690f6ed65e5c0e0e2274bf35ac49ff31d7988d483ce?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f81f58ad909e8a213ab0a690f6ed65e5c0e0e2274bf35ac49ff31d7988d483ce?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f81f58ad909e8a213ab0a690f6ed65e5c0e0e2274bf35ac49ff31d7988d483ce?s=96&d=mm&r=g","caption":"Vitor Silva"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/f81f58ad909e8a213ab0a690f6ed65e5c0e0e2274bf35ac49ff31d7988d483ce?s=96&d=mm&r=g"},"sameAs":["https:\/\/www.linkedin.com\/in\/vitormrsilva","https:\/\/x.com\/vitorsilva"]}]}},"_links":{"self":[{"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/posts\/2657","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/comments?post=2657"}],"version-history":[{"count":0,"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/posts\/2657\/revisions"}],"wp:attachment":[{"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/media?parent=2657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/categories?post=2657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/tags?post=2657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}