您的位置:首页 > 理论基础 > 计算机网络

[转]:在oracle中通过utl_http获得指定网页内容,支持中文

2012-08-28 18:07 309 查看
直接使用oracle中提供的包来实现读取指定页面的内容。

例如:
SET serveroutput ON SIZE 40000

DECLARE
req utl_http.req;
resp utl_http.resp;
value VARCHAR2(1000);
BEGIN

req := utl_http.begin_request('http://www.5ienet.com/online.asp');
resp := utl_http.get_response(req);
LOOP
utl_http.read_line(resp, value, TRUE);
dbms_output.put_line(value);
END LOOP;
utl_http.end_response(resp);
EXCEPTION
WHEN utl_http.end_of_body THEN
utl_http.end_response(resp);
END;

怎么样,是不是结果已经出来了,哎,不对怎么中文字符都显示成了乱码,呵呵,别急,将下面这行代码加在resp:=那行之前再试试。
utl_http.set_header(req, 'Content-Type', 'text/html; charset=gb2312');
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐