Oracle queries IP region information

Source: Internet
Author: User
 declare URL varchar2 (2000); req utl_http.req; resp utl_http.resp; value varchar2 (1000); region varchar2 (50 ); begin URL: = 'HTTP: // www.youdao.com/smartresult-xml/search.s? Type = IP \ & Q = 25.238.158.9 '; Req: = utl_http.begin_request (URL); resp: = utl_http.get_response (req); loop utl_http.read_line (resp, value, true ); if instr (value, '
  
   ')> 0 then dbms_output.put_line ('site reply '| value); If instr (value, '')> 0 then region: = substr (value, instr (value, '>', 1) + 1, instr (value, '', 2)-instr (value, '>', 2) -1); else region: = substr (value, instr (value, '>', 1) + 1, instr (value, '<', 2)-instr (value, '>', 2)-1); end if; If region = ''then dbms_output.put_line ('unknown address'); else dbms_output.put_line (region); end if; end loop; utl_http.end_response (RESP); Exception when utl_http.end_of_body then utl_http.end_response (RESP); end;/
  

Note: Run with DBA

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.