<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span lang="PT-BR">Jônatan,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="PT-BR"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="PT-BR">Dentro do que eu fiz vc aconselharia e pensaria em modificar o que para melhorar?
<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="PT-BR">Um grande abraço!</span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Paulo Henrique de A. S. Pimenta<br>
Cel/WhatsApp/Telegram: +5511981318435<br>
<br>
Sent from Mail for Windows 10</p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><o:p> </o:p></span></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:jdtatsch@gmail.com">Jônatan</a><br>
<b>Sent: </b>Friday, July 8, 2016 5:27 PM<br>
<b>To: </b><a href="mailto:paulopimenta6@hotmail.com">Paulo Henrique Pimenta</a>;
<a href="mailto:r-br@listas.c3sl.ufpr.br">a lista Brasileira oficial de discussão do programa R.</a><br>
<b>Subject: </b>Re: [R-br] Baixando dados do INMET com a biblioteca RCurl e bitops/Salvando arquivos em .txt</p>
</div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><o:p> </o:p></span></p>
</div>
<div>
<div dir="ltr">
<div>Nesse<a href="https://github.com/jdtatsch/inmetr/blob/master/README.md "> link</a> disponibilizo umas funções que fiz para importar os dados do site do inmet-bdmep para o R. O readme inclui exemplo de uso das funções. O script é baseado no post citado
no e-mail Paulo e nas instruções dadas no <a href="https://www.youtube.com/watch?v=o2fFUw8aSHE">vídeo </a>do Meetup R São Paulo (<i>Web scraping usando o R</i> por Julio Trecenti).</div>
<div>Testado no linux ubuntu somente. Em breve devo empacotar isso.<br>
</div>
<div>Qualquer problema, me avisem por gentileza.</div>
<div>Att.</div>
</div>
<div class="x_gmail_extra"><br>
<div class="x_gmail_quote">2016-07-08 13:03 GMT-03:00 Paulo Henrique Pimenta via R-br
<span dir="ltr"><<a href="mailto:r-br@listas.c3sl.ufpr.br" target="_blank">r-br@listas.c3sl.ufpr.br</a>></span>:<br>
<blockquote class="x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div lang="EN-US">
<div>
<p class="x_MsoNormal"><span lang="PT-BR">Olá Listeiros!</span></p>
<p class="x_MsoNormal"><u></u> <u></u></p>
<p class="x_MsoNormal"><span lang="PT-BR">Estou com um grande problema e acho que vcs podem me ajudar! Estou usando um script criado por mim a partir das dicas da própria lista:
<a href="http://r-br.2285057.n4.nabble.com/R-br-r-baixando-dados-inmet-td4660459.html" target="_blank">
http://r-br.2285057.n4.nabble.com/R-br-r-baixando-dados-inmet-td4660459.html</a> na qual usei o código como template para automatizar o download dos dados do inmet. Infelizmente estou com alguns problemas, um deles é que só consigo usar o código no Windows,
ou seja, no R do Windows e não do Linux (possuo o Windows 10 e o Ubuntu 16.04 no meu notebook).<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR">Os erros no meu Linux são referentes a biblioteca RCurl que mesmo reinstalado várias vezes e usado com a biblioteca bitops continuam a não funcionar. Outro problema que tenho é o não conhecimento sobre como salvar os
arquivos baixados em um .txt ao invés de alocar em variáveis como estou fazendo. Caso algum de vcs se interesse em mexer e melhorar o código segue ele abaixo:<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR">####################################################################################################################<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR">### <begin><u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR">library(bitops)<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR">library(RCurl)<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR">####################################################################<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR">dados_1 <- read.table(<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"> "E:/inmet/estacoes_2.txt",<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"> header=F,<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"> sep="\t")<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR">dados_1 <- data.frame(dados_1)<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR">#names(dados_1) <- c("cidades", "estacoes")<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR">######################################################################<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"># Links para login e dados<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR">myURL1 <- "<a href="http://www.inmet.gov.br/projetos/rede/pesquisa/inicio.php" target="_blank">http://www.inmet.gov.br/projetos/rede/pesquisa/inicio.php</a>"<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR">for (NUM in 1:length(dados_1[,2])){<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"> myURL2[NUM] <- "<a href="http://www.inmet.gov.br/projetos/rede/pesquisa/gera_serie_txt.php?&mRelEstacao=dados_1[,2][NUM]&btnProcesso=serie&mRelDtInicio=01/01/2002&mRelDtFim=01/01/2013&mAtributos=1,,,,1,1,,1,1,,,1,,,,," target="_blank">http://www.inmet.gov.br/projetos/rede/pesquisa/gera_serie_txt.php?&mRelEstacao=dados_1[,2][NUM]&btnProcesso=serie&mRelDtInicio=01/01/2002&mRelDtFim=01/01/2013&mAtributos=1,,,,1,1,,1,1,,,1,,,,,</a>"<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"># Dados para acesso<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR">myParams=list(<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"> mCod="SEU EMAIL",<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"> mSenha="SUA SENHA",<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"> btnProcesso = " Acessar ")<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"> myCurl <- getCurlHandle()<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"> curlSetOpt(cookiejar="cookies.txt", useragent="Mozilla/5.0", followlocation=TRUE, curl=myCurl)<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"> login <- postForm(myURL1, .params=myParams, curl=myCurl)<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"> dados[NUM] <- getURLContent(myURL2[NUM], curl=myCurl)<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"> exemplo[NUM] <- head(strwrap(dados[NUM], 70), 10000)<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"> }
<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR">### <end> </span><u></u><u></u></p>
<p class="x_MsoNormal"><u></u> <u></u></p>
<p class="x_MsoNormal"><span lang="PT-BR">###################################################################################################################</span></p>
<p class="x_MsoNormal"><u></u> <u></u></p>
<p class="x_MsoNormal"><span lang="PT-BR">O arquivo estacoes_2.txt esta aqui: </span>
<a href="http://s000.tinyupload.com/index.php?file_id=66921456922777880817" target="_blank"><span style="font-size:9.0pt; font-family:"Verdana",sans-serif; color:#a1d700">http://s000.tinyupload.com/?file_id=66921456922777880817</span></a><u></u><u></u></p>
<p class="x_MsoNormal"><u></u> <u></u></p>
<p class="x_MsoNormal"><span lang="PT-BR">Se alguém tiver interesse em modificar para melhorar o código fique a vontade!</span><u></u><u></u></p>
<p class="x_MsoNormal"><u></u> <u></u></p>
<p class="x_MsoNormal"><span lang="PT-BR">Um grande abraço a todos vcs!<u></u><u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span lang="PT-BR">Paulo.</span></p>
<p class="x_MsoNormal"><u></u> <u></u></p>
<p class="x_MsoNormal">Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986" target="_blank">
Mail</a> for Windows 10</p>
<p class="x_MsoNormal"><span style="font-size:12.0pt; font-family:"Times New Roman",serif"><u></u> <u></u></span></p>
</div>
</div>
<br>
_______________________________________________<br>
R-br mailing list<br>
<a href="mailto:R-br@listas.c3sl.ufpr.br">R-br@listas.c3sl.ufpr.br</a><br>
<a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" rel="noreferrer" target="_blank">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br>
Leia o guia de postagem (<a href="http://www.leg.ufpr.br/r-br-guia" rel="noreferrer" target="_blank">http://www.leg.ufpr.br/r-br-guia</a>) e forneça código mínimo reproduzível.<br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="x_gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div><font size="2" style="font-family:arial">###############################################################</font><br>
<span style="font-family:arial; font-size:small">## </span><span style="font-size:11px; text-align:center; background-color:rgb(239,239,239); color:rgb(150,150,150); font-family:Verdana,Arial,Helvetica,sans-serif; line-height:13px">Jônatan Dupont Tatsch</span></div>
<div><span style="font-family:arial; font-size:small">## </span><span style="color:rgb(150,150,150); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:10.909090995788574px; line-height:12.997159004211426px; text-align:center; background-color:rgb(239,239,239)">Professor
do Departamento de Física</span></div>
<div><span style="font-size:small; font-family:arial">## </span><span style="color:rgb(150,150,150); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:10.909090995788574px; line-height:12.997159004211426px; text-align:center; background-color:rgb(239,239,239)">Centro
de Ciências Exatas e Naturais (CCNE)</span><br>
</div>
<div><span style="font-size:small; font-family:arial">## </span><span style="color:rgb(150,150,150); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:10.909090995788574px; line-height:12.997159004211426px; text-align:center; background-color:rgb(239,239,239)">Universidade
Federal de Santa Maria - UFSM</span></div>
<div><span style="font-family:arial; font-size:small">## </span><span style="font-size:11px; text-align:center; background-color:rgb(239,239,239); color:rgb(150,150,150); font-family:Verdana,Arial,Helvetica,sans-serif; line-height:13px">Faixa de Camobi, Prédio
13 - Campus UFSM - </span><span style="font-size:11px; text-align:center; background-color:rgb(239,239,239); color:rgb(150,150,150); font-family:Verdana,Arial,Helvetica,sans-serif; line-height:13px">Santa Maria, RS, Brasil - 97105-900</span><br>
</div>
<div style="font-family:arial; font-size:small">## <span style="font-size:11px; text-align:center; background-color:rgb(239,239,239); color:rgb(150,150,150); font-family:Verdana,Arial,Helvetica,sans-serif; line-height:13px">Telefone: +55(55)33012083</span><br>
</div>
<div style="font-family:arial; font-size:small">## <span style="font-size:11px; text-align:center; background-color:rgb(239,239,239); color:rgb(150,150,150); font-family:Verdana,Arial,Helvetica,sans-serif; line-height:13px"><a href="http://www.ufsm.br/meteorologia" target="_blank">www.ufsm.br/meteorologia</a></span></div>
<div style="font-family:arial; font-size:small">###############################################################</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>