2010 Aug 11 10:14 AM
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...
2010 Aug 11 12:20 PM
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...
2010 Aug 11 12:20 PM
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
2010 Aug 11 12:33 PM
hmmm interesting,
but isn't there a way to actually read the html? (the one that is sent to the web browser)
2010 Aug 11 3:04 PM
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
2010 Aug 11 4:04 PM
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
2010 Aug 23 10:42 AM
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
2010 Aug 11 3:12 PM
Hello friend,
you can also try with function module HTTP_GET.
Best Regards,
Jerry