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

直接使用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');

原文地址:https://www.cnblogs.com/vigarbuaa/p/2660633.html