楼主: 邢不行
6350 14

[原创博文] sas抓取网页数据 提示找不到主机名 [推广有奖]

已卖:1906份资源

院士

10%

还不是VIP/贵宾

-

威望
1
论坛币
26755 个
通用积分
155.8944
学术水平
489 点
热心指数
509 点
信用等级
460 点
经验
53138 点
帖子
585
精华
26
在线时间
1199 小时
注册时间
2010-4-30
最后登录
2025-12-31

楼主
邢不行 在职认证  发表于 2011-10-31 21:24:45 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
最近想学如何用sas抓取网页数据,搜索了下论坛里的帖子,感谢很多大神的指导,比如elek.me的博文就详细介绍了怎么做:http://saslist.com/elek/2010/09/15/%E9%80%9A%E8%BF%87-sas-%E8%AF%BB%E5%8F%96%E7%BD%91%E9%A1%B5%E5%86%85%E5%AE%B9/

博文中的程序我贴在下面:
  1. filename readweb url %nrstr("http://detail.zol.com.cn/cell_phone_index/subcate57_list_s528_1.html") lrecl=60000;

  2. data tmp;
  3.         infile readweb lrecl=60000 dlm="><";
  4.         retain flag 0;
  5.         length title1 $ 20;
  6.         if flag=0 then do;
  7.                 title="手机名称";
  8.                 input @'id="proName_' @'>' content :$50. @@;
  9.                 flag=1;
  10.                 num+1;
  11.                 if title="手机名称" then title1="name";
  12.                 output;
  13.         end;
  14.         input @'<dd class="tit_new">' title :$50. @;
  15.         if title="上市日期" then do;
  16.                 flag=0;
  17.         end;
  18.         input @'<dd class="con_new">' content :$50. @@;
  19.         if scan(content,1,"=")="a href" then input content :$50. @@;
  20.         if title="所属系列" then title1="series";
  21.         if title="操作系统" then title1="os";
  22.         if title="手机类型" then title1="type";
  23.         if title="网络模式" then title1="net";
  24.         if title="主屏尺寸" then title1="screen_size";
  25.         if title="主屏色彩" then title1="screen_color";
  26.         if title="触摸屏:" then title1="screen_type";
  27.         if title="摄像头像" then title1="camera";
  28.         if title="蓝牙功能" then title1="bluetooth";
  29.         if title="上市日期" then title1="date";
  30.         output;
  31.         drop flag;
  32. run;

  33. proc transpose data=tmp out=want(drop=_name_);
  34.         var content;
  35.         by num;
  36.         id title1;
  37. run;
复制代码



但是我运行里面的程序之后sas会出现如下提示:


NOTE: 无法连接主机“detail.zol.com.cn”。请检查主机名称是否有效。
ERROR: 主机名“detail.zol.com.cn”没有找到.


我试了下论坛中其他帖子中用的程序(每个程序都大同小异),都会出现这个问题,希望哪位大神能够帮忙解决下,谢谢!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:抓取网页数据 Transpose Bluetooth filename Content content title 网页 主机 程序

已有 1 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
Tigflanker + 1 + 2 + 3 + 4 已关注,跟进中

总评分: 论坛币 + 1  学术水平 + 2  热心指数 + 3  信用等级 + 4   查看全部评分

沙发
邢不行 在职认证  发表于 2011-10-31 21:32:37
大家也可以尝试下运行看看这个程序,看看会不会出现相同的问题
谢谢啦
不管去哪里 只要在路上

藤椅
yiqiu127 发表于 2011-10-31 21:33:07
我只会用SAs里面的实验设计,编程好难

板凳
天请 发表于 2011-10-31 21:43:26
我刚试了一下,确实会遇到这样的问题,不知道原因是什么
大道求诸于己,成功在于执着;凭直觉引路,靠实力说话.

报纸
numman 发表于 2011-10-31 22:07:08
官方解释是反向查询函数的问题:

When you use the FTP, URL, or SOCKET engine in SAS® 9.2 Phase 1 (TS1M0) in a FILENAME statement, you might receive the following error if the remote host's HOSTNAME cannot be resolved to a valid remote host name:

NOTE: UNABLE TO CONNECT TO HOST host name. CHECK VALIDITY OF HOST NAME.ERROR: OPEN FAILED FOR FILE file nameERROR: HOSTNAME host name NOT FOUND.
This error is likely caused by a problem with the reverse lookup function.
Select the Hot Fix tab in this note to access the hot fix for this issue.
An example for using the FTP engine would be the following:

filename lcl ftp 'test.sas7bdat' host='<host_name>' user='<userid>' prompt
         cd='<Path_to_the_folder_where_test.sas7bdat_resides>' recfm=s debug;

FILENAME rmt 'c:\test.sas7bdat' recfm=n;

DATA _NULL_;
   N=1;
   INFILE lcl NBYTE=n;
   INPUT;
   FILE rmt ;
   PUT _INFILE_ @@;
RUN;


建议:重装一个好用的SAS

或者按照官方说法下载一个HOT FIX...

下载地址:http://ftp.sas.com/techsup/download/hotfix/f9_sbcs_prod_list.html#034098

Hot Fix 好用与否 未测试。
已有 1 人评分学术水平 热心指数 收起 理由
njmch + 1 + 1 Good

总评分: 学术水平 + 1  热心指数 + 1   查看全部评分

地板
邢不行 在职认证  发表于 2011-10-31 22:11:54
https://bbs.pinggu.org/forum.php? ... F8%D2%B3&page=1
这个帖子中 爱萌  说是因为9.2版本的问题,9.1.3就可以
真心不知道为什么高级的版本反而不行...
不管去哪里 只要在路上

7
邢不行 在职认证  发表于 2011-10-31 22:12:27
numman 发表于 2011-10-31 22:07
官方解释是反向查询函数的问题:When you use the FTP, URL, or SOCKET engine in SAS® 9.2 Phase 1 (T ...
谢谢! 我会尝试下的!
不管去哪里 只要在路上

8
tj0412ymy 发表于 2011-10-31 22:53:07
面临同样的Problem,同求Answer!
对SAS和统计方面感兴趣的朋友,请加SAS学习和认证讨论群:169157207。欢迎在群上讨论!

9
kuhasu 发表于 2011-11-1 00:42:20
NOTE: LOST CARD.
flag=1 title1=name title=手机名称 content=联想乐Phone(3GW100) num=1 _ERROR_=1 _N_=1

10
邢不行 在职认证  发表于 2011-11-1 08:14:02
kuhasu 发表于 2011-11-1 00:42
NOTE: LOST CARD.
flag=1 title1=name title=手机名称 content=联想乐Phone(3GW100) num=1 _ERROR_=1 _N ...
只要不显示连接不上主机就应该没有问题。
您回复中显示的问题可能是因为那个连接的网页已经有所改变,所以后面的data步会小小的有点问题
不管去哪里 只要在路上

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-5 07:38