論壇新手。我想知道如果有人知道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