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

How to read the HTML code from a webpage

Former Member
0 Likes
2,657

Hi, I want to be able to read the HTML code of a web page

In order to extract some info from some pages.

How can I do that?

is it using cl_http_client ? I played with that class a bit, but wih no sucess to what I need...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,589

Not sure whether the HTML code of a webpage can be read in ABAP. But webservices can be invoked through it.

Check this link.....

http://sample-code-abap.blogspot.com/2009/05/simple-code-consume-web-service-using.html

Hi, I want to be able to read the HTML code of a web page

In order to extract some info from some pages.

How can I do that?

is it using cl_http_client ? I played with that class a bit, but wih no sucess to what I need...

6 REPLIES 6
Read only

Former Member
0 Likes
1,590

Not sure whether the HTML code of a webpage can be read in ABAP. But webservices can be invoked through it.

Check this link.....

http://sample-code-abap.blogspot.com/2009/05/simple-code-consume-web-service-using.html

Read only

0 Likes
1,589

hmmm interesting,

but isn't there a way to actually read the html? (the one that is sent to the web browser)

Read only

former_member848108
Active Participant
0 Likes
1,589

Hi RagnaRock,

You can use the following form, hope it helps you.

Regards,

Ozcan.



form get_data_from_url using iv_url type clike changing iv_data type string.

DATA: HTTP_CLIENT TYPE REF TO IF_HTTP_CLIENT .
  clear  iv_data.

  CALL METHOD CL_HTTP_CLIENT=>CREATE_BY_URL
       EXPORTING
        URL                = IV_URL
*          PROXY_HOST         = '10.1.1.1'
*          PROXY_SERVICE      = '1234'
*       SSL_ID             =
       IMPORTING
         CLIENT             = HTTP_CLIENT
       EXCEPTIONS
         ARGUMENT_NOT_FOUND = 1
         PLUGIN_NOT_ACTIVE  = 2
         INTERNAL_ERROR     = 3
         OTHERS             = 4.

  CHECK SY-SUBRC = 0.

  CALL METHOD HTTP_CLIENT->SEND
    EXCEPTIONS
      HTTP_COMMUNICATION_FAILURE = 1
      HTTP_INVALID_STATE         = 2.

  CHECK SY-SUBRC = 0.

  CALL METHOD HTTP_CLIENT->RECEIVE
    EXCEPTIONS
      HTTP_COMMUNICATION_FAILURE = 1
      HTTP_INVALID_STATE         = 2
      HTTP_PROCESSING_FAILED     = 3.
  CHECK SY-SUBRC = 0.

  iv_data = HTTP_CLIENT->RESPONSE->GET_CDATA( ).

endform.                    "get_data_from_url

Edited by: Ozcan Gurdal on Aug 11, 2010 4:07 PM

Read only

0 Likes
1,589

I've tried this, but I'm getting sy-subrc = 1 when I do the receive part.

I'm sure the site exists and is online, what could be the problem?

edit

actually I only get subrc = 1 if I execute this code outside the form, If I do it just like you did, using:

PERFORM get_data_from_url USING 'http://www.jogosbaratos.net' CHANGING html_code.

I always get subrc = 0 but html_code comes empty

any idea?

Edited by: RagnaRock on Aug 11, 2010 5:05 PM

edit2

the http_get did work

Edited by: RagnaRock on Aug 11, 2010 6:13 PM

Read only

0 Likes
1,589

I solved this using the FM http_get, but I'm having some problems with the encoding.

for example if the webpage apears 'é' in my table apears 'é'

is there any way to change the text enconding?

thanks

Read only

JerryWang
Product and Topic Expert
Product and Topic Expert
0 Likes
1,589

Hello friend,

you can also try with function module HTTP_GET.

Best Regards,

Jerry