出处:http://elek.me/read-contents-from-websites-using-sas.html
-
- filename readweb url %nrstr("http://detail.zol.com.cn/cell_phone_index/subcate57_list_s528_1.html") lrecl=60000;
-
- data tmp;
- infile readweb lrecl=60000 dlm="><";
- retain flag 0;
- length title1 $ 20;
- if flag=0 then do;
- title="手机名称";
- input @'id="proName_' @'>' content :$50. @@;
- flag=1;
- num+1;
- if title="手机名称" then title1="name";
- output;
- end;
- input @'<dd class="tit_new">' title :$50. @;
- if title="上市日期" then do;
- flag=0;
- end;
- input @'<dd class="con_new">' content :$50. @@;
- if scan(content,1,"=")="a href" then input content :$50. @@;
- if title="所属系列" then title1="series";
- if title="操作系统" then title1="os";
- if title="手机类型" then title1="type";
- if title="网络模式" then title1="net";
- if title="主屏尺寸" then title1="screen_size";
- if title="主屏色彩" then title1="screen_color";
- if title="触摸屏:" then title1="screen_type";
- if title="摄像头像" then title1="camera";
- if title="蓝牙功能" then title1="bluetooth";
- if title="上市日期" then title1="date";
- output;
- drop flag;
- run;
-
- proc transpose data=tmp out=want(drop=_name_);
- var content;
- by num;
- id title1;
- run;


雷达卡


京公网安备 11010802022788号







