‎2015 Apr 17 1:41 PM
Hello.
I have such task and need an advise. I need to read value from Web page. I have a link with an index, which changes every day. It has the same position and length and I need to upload it to the system every morning automatically.
How can I read html code of the web page and parse it?
Kind regards.
Pavlo
‎2015 Apr 17 2:18 PM
‎2015 Apr 17 2:18 PM
‎2015 Apr 17 2:19 PM
Hi,
cl_html_client can be used to get the HTML page.
See FORM do_xml_fetch_1 .
Regards .
FORM do_xml_fetch_1
CHANGING
response_string_2 TYPE xstring .
DATA: client TYPE REF TO if_http_client .
TRANSLATE p_url TO LOWER CASE .
TRANSLATE p_host TO LOWER CASE .
TRANSLATE p_port TO LOWER CASE .
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = p_url
proxy_host = p_host
proxy_service = p_port
IMPORTING
client = client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4.
CHECK sy-subrc EQ 0 .
CALL METHOD client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2.
CHECK sy-subrc EQ 0 .
CALL METHOD client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
CHECK sy-subrc EQ 0 .
DATA: response_string_1 TYPE string .
response_string_1 = client->response->get_cdata( ).
TRY.
CALL METHOD cl_bcs_convert=>string_to_xstring
EXPORTING
iv_string = response_string_1
RECEIVING
ev_xstring = response_string_2.
CATCH cx_bcs .
ENDTRY.
ENDFORM . "do_xml_fetch_1