1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| PROCÉDURE p993_GET_Qry_To_avia_weather
IS
l_http_request UTL_HTTP.req;
l_http_response UTL_HTTP.resp;
l_buffer_size NOMBRE (10): = 512;
l_line_size NOMBRE (10): = 70;
NOMBRE l_lines_count (10): = 10;
l_string_request VARCHAR2 (512);
l_url VARCHAR2 (512);
l_line VARCHAR2 (128);
l_raw_data RAW (512);
l_clob_response CLOB;
BEGIN
/ *
envoyer la requête HTTP en fonction de la structure du fichier html source à l'adresse: http:/aviationweather.gov/adds/metars/:
...
<FORM name = "textForm" method = "GET" action = "">
<INPUT SIZE=14 NAME="station_ids" type="text">
............
<INPUT NAME="submitmet" TYPE="submit" VALUE="Submit">
<INPUT Type="reset" VALUE="Reset FORM"> </ FORM>
....... ...
* /
l_url: = 'http://aviationweather.gov/adds/metars?station_ids =' | |: METAR_BLOCK.metars;
l_http_request: = UTL_HTTP.begin_request (url => l_url, method => 'GET');
UTL_HTTP.set_header (r => l_http_request, nom => 'User-Agent', valeur => 'IE8');
UTL_HTTP.set_header (l_http_request, 'Host', 'aviationweather.gov');
l_http_response: = UTL_HTTP.get_response (l_http_request);
Dbms_output.put_line («Response> code_état:" '| | l_http_response.status_code | |' "');
Dbms_output.put_line («Response> reason_phrase:" '| | l_http_response.reason_phrase | |' "');
Dbms_output.put_line («Response> http_version:" '| | l_http_response.http_version | |' "');
BEGIN - bloc de réponse
<< Response_loop >>
LOOP
UTL_HTTP.read_raw (l_http_response, l_raw_data, l_buffer_size);
l_clob_response: = l_clob_response | | UTL_RAW.cast_to_varchar2 (l_raw_data);
Response_loop END LOOP;
EXCEPTION
QUAND PUIS UTL_HTTP.end_of_body
UTL_HTTP.end_response (l_http_response);
FIN; - Bloc de réponse
Dbms_output.put_line («Response> longueur:" '| | LONGUEUR (l_clob_response) | |' "');
Dbms_output.put_line (CHR (10) | | '=== Imprimer premier' | | | | l_lines_count «lignes de réponse HTTP ... === '| | CHR (10) | | CHR (10));
<< Print_response >>
For i in 0 .. CEIL (LONGUEUR (l_clob_response) / l_line_size) - 1 LOOP
l_line: = SUBSTR (l_clob_response, i * l_line_size + 1, l_line_size);
Dbms_output.put_line ('[' | | LPAD (i, 2, '0 ') | |']: '| | SUBSTR (TRIM (l_line), 1,50) | |' ... ');
EXIT WHEN i> l_lines_count - 1;
Print_response END LOOP;
SI l_http_request.private_hndl IS NOT NULL THEN
UTL_HTTP.end_request (l_http_request);
END IF;
SI l_http_response.private_hndl IS NOT NULL THEN
UTL_HTTP.end_response (l_http_response);
END IF; |
Partager