using web page information: incorrect filename

Discuss RoboTask here
Post Reply
kravtsov
Posts: 6
Joined: Thu Nov 10, 2016 7:09 am

using web page information: incorrect filename

Post by kravtsov »

Hi! I'm using web page information to download a few thousands files (check box Auto downloading file).
Webserver offers to dowload file with name "XXX.csv", but Robotask use only "DownloadFile(ID).do" where ID is my variable in loop.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1598268565
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task35"
Hide=INTEGER|0
ID=INTEGER|154953626
LogOnAsUser=INTEGER|1
Name=STRING|"Copy of mysite"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|1
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""ID"" with value ""533"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"1"
varname=STRING|"ID"
varvalue=STRING|"533"

[Actions\Action2]
ActionID=STRING|"A_LOOP_WHILE"
Enabled=INTEGER|-1
Name=STRING|"While loop"
Params=FOLDER

[Actions\Action2\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"3"
type=STRING|"1"
value1=STRING|"{ID}"
value2=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_WD_PAGEINFO"
Enabled=INTEGER|-1
Name=STRING|"Web Page Information"
Params=FOLDER

[Actions\Action3\Params]
address=STRING|"http://mysite.com/DownloadFile.do?&id={ID}"
autodownload=STRING|"1"
autologon=STRING|"0"
downloadfolder=STRING|"C:\1-600\"
gethtml=STRING|"0"
getlinks=STRING|"0"
gettext=STRING|"0"
hide=STRING|"0"
htmlbodyonly=STRING|"0"
keep=STRING|"1"
overwrite=STRING|"0"
textbodyonly=STRING|"0"

[Actions\Action4]
ActionID=STRING|"A_GENERAL_PAUSE"
Enabled=INTEGER|-1
Name=STRING|"Delay"
Params=FOLDER

[Actions\Action4\Params]
delay=STRING|"800"
dimension=STRING|"0"

[Actions\Action5]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""ID"""
Params=FOLDER

[Actions\Action5\Params]
incement=STRING|"-1"
vaiable=STRING|"ID"

[Actions\Action6]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
Oleg
Site Admin
Posts: 3010
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: using web page information: incorrect filename

Post by Oleg »

It seems the site returns dynamic file as attachment in response

Try to use Download Files action instead of Web page information
Look at my example below:

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task446"
Hide=INTEGER|0
ID=INTEGER|-583639200
LogOnAsUser=INTEGER|1
Name=STRING|"Copy of mysite (ver 2)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|1
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""ID"" with value ""533"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"1"
varname=STRING|"ID"
varvalue=STRING|"533"

[Actions\Action2]
ActionID=STRING|"A_LOOP_WHILE"
Enabled=INTEGER|-1
Name=STRING|"While loop"
Params=FOLDER

[Actions\Action2\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"3"
type=STRING|"1"
value1=STRING|"{ID}"
value2=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_INET_DOWNLOAD"
Enabled=INTEGER|-1
Name=STRING|"Download files and save in ""C:\1-600"""
Params=FOLDER

[Actions\Action3\Params]
action=STRING|"0"
authorization=STRING|"0"
file0=STRING|"http://mysite.com/DownloadFile.do?id={ID}"
filecount=STRING|"1"
password=STRING|"1268313505132511324313504"
proxykind=STRING|"0"
saveas=STRING|"0"
saveasname=STRING|"*.*"
savedir=STRING|"C:\1-600"
useproxy=STRING|"0"

[Actions\Action4]
ActionID=STRING|"A_GENERAL_PAUSE"
Enabled=INTEGER|-1
Name=STRING|"Delay"
Params=FOLDER

[Actions\Action4\Params]
delay=STRING|"800"
dimension=STRING|"0"

[Actions\Action5]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""ID"""
Params=FOLDER

[Actions\Action5\Params]
incement=STRING|"-1"
vaiable=STRING|"ID"

[Actions\Action6]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Oleg Yershov
Oleg
Site Admin
Posts: 3010
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: using web page information: incorrect filename

Post by Oleg »

Also you can rename downloaded file to desired name in each iteration in the loop in your existing task.
Oleg Yershov
kravtsov
Posts: 6
Joined: Thu Nov 10, 2016 7:09 am

Re: using web page information: incorrect filename

Post by kravtsov »

Oleg wrote:It seems the site returns dynamic file as attachment in response
exactly

In first step i have URL "http://mysite.com/[b]DownloadFile.do[/b]?id={ID}"
Browser (firefox etc) automatically download file "{ID}.pdf"
But Robotask use for the file name a part of the http-request "DownloadFile.do"

To use the file download module in my case, it's not clear how to get authorization. The functions built into the module do not help.

I hope you understand me. My English is poor.
Oleg
Site Admin
Posts: 3010
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: using web page information: incorrect filename

Post by Oleg »

You can rename the file after download
Look at my example, step #5

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task414"
Hide=INTEGER|0
ID=INTEGER|-620735491
LogOnAsUser=INTEGER|1
Name=STRING|"Copy of mysite (ver 3)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|1
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""ID"" with value ""533"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"1"
varname=STRING|"ID"
varvalue=STRING|"533"

[Actions\Action2]
ActionID=STRING|"A_LOOP_WHILE"
Enabled=INTEGER|-1
Name=STRING|"While loop"
Params=FOLDER

[Actions\Action2\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"3"
type=STRING|"1"
value1=STRING|"{ID}"
value2=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_WD_PAGEINFO"
Enabled=INTEGER|-1
Name=STRING|"Web Page Information"
Params=FOLDER

[Actions\Action3\Params]
address=STRING|"http://mysite.com/DownloadFile.do?&id={ID}"
autodownload=STRING|"1"
autologon=STRING|"0"
downloadfolder=STRING|"C:\1-600\"
gethtml=STRING|"0"
getlinks=STRING|"0"
gettext=STRING|"0"
hide=STRING|"0"
htmlbodyonly=STRING|"0"
keep=STRING|"1"
overwrite=STRING|"0"
textbodyonly=STRING|"0"

[Actions\Action4]
ActionID=STRING|"A_GENERAL_PAUSE"
Enabled=INTEGER|-1
Name=STRING|"Delay"
Params=FOLDER

[Actions\Action4\Params]
delay=STRING|"800"
dimension=STRING|"0"

[Actions\Action5]
ActionID=STRING|"A_FILE_RENAME"
Enabled=INTEGER|-1
Name=STRING|"Rename File"
Params=FOLDER

[Actions\Action5\Params]
count=STRING|"1"
file0=STRING|"C:\1-600\DownloadFile.do"
ifexists=STRING|"1"
mask=STRING|"{ID}.csv"
subdirs=STRING|"0"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""ID"""
Params=FOLDER

[Actions\Action6\Params]
incement=STRING|"-1"
vaiable=STRING|"ID"

[Actions\Action7]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

Oleg Yershov
Post Reply