论坛新手。我想知道如果有人知道Curl如何使用SAS处理动态页面。例如,我尝试使用下面类似的代码来卷曲Base SAS中的以下动态页面:https://mysite.com/kl/livelink.exe?func=ll&objId=123,结果显示'objId'不被识别为内部或外部命令,可操作程序或批处理文件。程序或批处理文件。任何人有任何想法?提前致谢。sas curl登录到安全的动态网站
%let a = ll;
%let b = 1117016710;
data _null_;
call symput ('curl_cmd', "&curl_executable -k -u &userpass %nrstr(https://mysite.com/kl/livelink.exe?func=)&a^%nrstr(&objId=)&b ");
run;
filename curl pipe "&curl_cmd" lrecl=32767;
data tmp;
length xml $&maxchars;
infile curl truncover end=eof;
input @1 xml $&maxchars..;
if lengthn(xml) ge &maxchars then do;
put "ERROR: FAILED FOR process BECAUSE XML WAS > &maxchars CHARS";
put "OBSERVATION: " _n_;
put xml;
stop;
end;
run;
filename curl clear;
the results shows:
filename curl pipe "&curl_cmd" lrecl=32767;
WARNING: Apparent symbolic reference OBJID not resolved.
PROCESS=C:\test\curl\curl.exe -k -u user:pwd
https://mysite.com/kl/livelink.exe?func=ll^&objId=1117016710,
RECFM=V,LRECL=32767
Stderr output:
Total Received Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0
0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
NOTE: 0 records were read from the infile CURL.
NOTE: The data set WORK.TMP has 0 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.35 seconds
乔的建议后,我做了一些改动,这里是下面的结果:
%let curl_executable = C:\test\curl\curl.exe;
%let maxchars = 3000;
%let userpass = user:pwd;
%let a = ll;
%let b = 1117016710;
%let curl_cmd=&curl_executable -k -u &userpass %nrstr(https://mysite.com/kl/livelink.exe?func=)&a.%nrstr(&objId)=&b ;
%put &=curl_cmd;
data _null_;
call symput ('curl_cmd', '&curl_executable -k -u &userpass %nrstr(https://mysite.com/kl/livelink.exe?func=)&a.%nrstr(&objId)=&b');
run;
%put &=curl_cmd;
filename curl pipe "&curl_cmd" lrecl=32767;
data tmp;
length xml $&maxchars;
infile curl truncover end=eof;
input @1 xml $&maxchars..;
if lengthn(xml) ge &maxchars then do;
put "ERROR: FAILED FOR process BECAUSE XML WAS > &maxchars CHARS";
put "OBSERVATION: " _n_;
put xml;
stop;
end;
run;
filename curl clear;
结果日志文件的回报:
37 %let curl_executable = C:\test\curl\curl.exe;
38 %let maxchars = 3000;
39 %let userpass = user:pwd;
40 %let a = ll;
41 %let b = 1117016710;
42 %let curl_cmd=&curl_executable -k -u &userpass
42 ! %nrstr(https://mysite.com/kl/livelink.exe?func=)&a.%nrstr(&objId)=&b
42 ! ;
43 %put &=curl_cmd;
CURL_CMD=C:\test\curl\curl.exe -k -u user:pwd
https://mysite.com/kl/livelink.exe?func=ll&objId=1117016710
44
45 data _null_;
46 call symput ('curl_cmd', '&curl_executable -k -u &userpass
46 ! %nrstr(https://mysite.com/kl/livelink.exe?func=)&a.%nrstr(&objId)=&b'
46 !);
47 run;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
48 %put &=curl_cmd;
CURL_CMD=C:\test\curl\curl.exe -k -u user:pwd
https://mysite.com/kl/livelink.exe?func=ll&objId=1117016710
49
50 filename curl pipe "&curl_cmd" lrecl=32767;
51 data tmp;
52 length xml $&maxchars;
53
54 infile curl truncover end=eof;
55 input @1 xml $&maxchars..;
56
57 if lengthn(xml) ge &maxchars then do;
58 put "ERROR: FAILED FOR process BECAUSE XML WAS > &maxchars CHARS";
59 put "OBSERVATION: " _n_;
60 put xml;
61 stop;
62 end;
63 run;
NOTE: The infile CURL is:
Unnamed Pipe Access Device,
PROCESS=C:\test\curl\curl.exe -k -u user:pwd
https://mysite.com/kl/livelink.exe?func=ll&objId=1117016710,
RECFM=V,LRECL=32767
Stderr output:
Total Received Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0
0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
'objId' is not recognized as an internal or external command,
operable program or batch file.
NOTE: 0 records were read from the infile CURL.
NOTE: The data set WORK.TMP has 0 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.43 seconds
cpu time 0.04 seconds
64 filename curl clear;
NOTE: Fileref CURL has been deassigned.
65
66
67 proc print data=tmp;
68 run;
NOTE: No observations in data set WORK.TMP.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
你需要做的第一件事是通过工艺试验串组输出。复制/粘贴从“=”到逗号前的所有内容。在命令行执行它。如果这样做,那么你有一些问题正确地得到命令处理器;如果这不起作用,请修复它,使其可以正常工作,然后更改SAS以使宏变量与该变量匹配。 – Joe