Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Read HTML code from web link

Former Member
0 Likes
772

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

1 ACCEPTED SOLUTION
Read only

guilherme_frisoni
Contributor
0 Likes
611

Hi Pavel,

search SCN for CL_HTTP_CLIENT, you will get multiple examples.

Such as:

Regards,

Frisoni

2 REPLIES 2
Read only

guilherme_frisoni
Contributor
0 Likes
612

Hi Pavel,

search SCN for CL_HTTP_CLIENT, you will get multiple examples.

Such as:

Regards,

Frisoni

Read only

rosenberg_eitan
Active Contributor
0 Likes
611

Hi,

cl_html_client can be used to get the HTML page.

See

  

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