Routine Base Robot - Access Site and Download File!

Team, good night.

One problem to help us ?

How is to write the code at Knime, about this ?

 - Step 1

#Teste - Direct

#!/bin/bash

echo "Acess Site"
curl -S --request POST \
  --url 'http://www.directdial.com.br/dc0800web/painel/login' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data 'login=varejo&password=Varejo4253%230805' \
  --cookie-jar cookie.txt

Step 2

echo "Download File"
curl --request GET \
  --url 'http://www.directdial.com.br/dc0800web/relatorios/venda-produto-separado?operador_cod=&exportar=sim&data_ini=22%252F06%252F2016&hora_ini=00%253A00&data_fim=23%252F06%252F2016&hora_fim=23%253A59' \
  --header 'cache-control: no-cache' \
  --header 'postman-token: 6fcaac35-754d-9b7c-fe62-88b17bbbfc0e' \
  --cookie cookie.txt \
  --output report.csv

echo "End Process!"

 

I Try with R Node:

 

library(jsonlite)
library(curl)
library(openssl)
library(httr)

login  = "Varejo"
password = "Varejo4253#0805"
url_report = "http://www.directdial.com.br/dc0800web/relatorios/venda-produto-separado?operador_cod=&exportar=sim&data_ini=22%2F06%2F2016&hora_ini=00%3A00&data_fim=23%2F06%2F2016&hora_fim=23%3A59"
url <- "http://www.directdial.com.br/dc0800web/painel/index"
content_type("application/x-www-form-urlencoded")
content_type("postman-token: 6fcaac35-754d-9b7c-fe62-88b17bbbfc0e")

# Direct Call Test
req <- httr::POST(url, content_type("application/x-www-form-urlencoded"), add_headers(Authorization = c(login,password)))
req
json <- httr::content(req, as = "text");json

c=cookies(req);c
set_cookies(.cookies=c(PHPSESSID = c1))

c1=c$PHPSESSID;c1

req1 <- httr::GET(url_report,add_headers(Authorization = c(login,password)));req1

x= paste("PHPSESSID",c1);x

json <- httr::content(req1, as = "text");json

Could you help me, please ?

 

Regards,

Demetrius.

So basically you want to retrieve a file after having automatically authenticated to a website.

You should look into the Palladian/Selenium nodes for this task. They allow to simulate interactions and perform GET/POST etc. with any web site.

There is a dedicated Board for them here on the KNIME forum. Have a look and post again there if you need additional help.

Cheers,
Marco.

I hope this will help you