Power Builder - Recoger datos web

 
Vista:

Recoger datos web

Publicado por Jorge (12 intervenciones) el 27/04/2011 17:30:59
Buenas, alguien podría indicarme como poder recoger datos de una URL o un html. No encuentro información al respecto. Necesito almacenar en mi base de datos información de unas páginas web que no tienen servicios web y lo estoy intentando con GetUrl pero luego no puedo tratar los datos que recibo. Muchas gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

Recoger datos web

Publicado por isaac matal (8 intervenciones) el 28/04/2011 15:36:29
lo que puedes hacer es capturar el source de la pagina web o xml, lo que recoge la funcion GetUrl es els ource de la pagina como un Blob que despues puedes convertir a texto guardandolo en un archivo usando Filewrite luego podrías recorrer el archivo creado buscando por una cadena de texto especifica y a partir de ahi hacer un mid para extraer la parte del texto que te interesa.

aqui te dejo un ejemplo que extrae desde un xml en linea el tipo de cambio para dolares canadienses a euros.

esta hecho en PB7.

---- copia esto en un archivo de texto y luego importalo a una PBL
$PBExportHeader$nc_internet_results.sru
forward
global type nc_internet_results from internetresult
end type
end forward

global type nc_internet_results from internetresult
end type
global nc_internet_results nc_internet_results

forward prototypes
public function integer internetdata (blob data)
end prototypes

public function integer internetdata (blob data);long ll_fhandle
MessageBox("Returned HTML", String(data))
ll_fhandle = FileOpen("data.dat", StreamMode!, Write!, LockWrite!, Replace!)
filewrite(ll_fhandle, data)
fileclose(ll_fhandle)
return 1
end function
on nc_internet_results.create
call super::create
TriggerEvent( this, "constructor" )
end on

on nc_internet_results.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on

---- copia esto en un archivo de texto y luego importalo a una PBL
$PBExportHeader$w_euros.srw
forward
global type w_euros from window
end type
type p_1 from picture within w_euros
end type
type st_2 from statictext within w_euros
end type
type st_1 from statictext within w_euros
end type
type sle_1 from singlelineedit within w_euros
end type
type sle_2 from singlelineedit within w_euros
end type
type cb_13 from commandbutton within w_euros
end type
type sle_3 from singlelineedit within w_euros
end type
end forward

global type w_euros from window
integer width = 1966
integer height = 596
boolean titlebar = true
string title = "Oficial Exchange Rate from Canadian Bank"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 12632256
string icon = "C:\Applications\Euro.ico"
p_1 p_1
st_2 st_2
st_1 st_1
sle_1 sle_1
sle_2 sle_2
cb_13 cb_13
sle_3 sle_3
end type
global w_euros w_euros

on w_euros.create
this.p_1=create p_1
this.st_2=create st_2
this.st_1=create st_1
this.sle_1=create sle_1
this.sle_2=create sle_2
this.cb_13=create cb_13
this.sle_3=create sle_3
this.Control[]={this.p_1,&
this.st_2,&
this.st_1,&
this.sle_1,&
this.sle_2,&
this.cb_13,&
this.sle_3}
end on

on w_euros.destroy
destroy(this.p_1)
destroy(this.st_2)
destroy(this.st_1)
destroy(this.sle_1)
destroy(this.sle_2)
destroy(this.cb_13)
destroy(this.sle_3)
end on

type p_1 from picture within w_euros
integer x = 1481
integer y = 40
integer width = 123
integer height = 88
string picturename = "C:\Applications\64Euro.jpg"
boolean focusrectangle = false
end type

type st_2 from statictext within w_euros
integer x = 169
integer y = 188
integer width = 594
integer height = 64
integer textsize = -10
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 32768
long backcolor = 12632256
string text = "1 Canadian Dollar ="
boolean focusrectangle = false
end type

type st_1 from statictext within w_euros
integer x = 151
integer y = 316
integer width = 608
integer height = 64
integer textsize = -10
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 32768
long backcolor = 12632256
string text = "Exchange Rate Date:"
boolean focusrectangle = false
end type

type sle_1 from singlelineedit within w_euros
integer x = 763
integer y = 320
integer width = 485
integer height = 84
integer taborder = 80
integer textsize = -10
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 32768
long backcolor = 12632256
boolean border = false
end type

type sle_2 from singlelineedit within w_euros
integer x = 768
integer y = 192
integer width = 379
integer height = 80
integer taborder = 80
integer textsize = -10
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 32768
long backcolor = 12632256
boolean border = false
end type

type cb_13 from commandbutton within w_euros
integer x = 1467
integer y = 28
integer width = 402
integer height = 112
integer taborder = 10
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = " Retrieve"
end type

event clicked;String ls_Headers, ls_URL,ls_args, ls_text
Long ll_Length, filehnd, ll_pos
Inet iinet_1
Blob lblob_args
integer result

nc_internet_results iir_Results1
This.GetContextService("Internet", iinet_1 )
iir_Results1 = CREATE nc_internet_results
ls_URL= "http://"+sle_3.text
ls_args = ""
lblob_args = Blob(ls_args)
ll_Length = Len(lblob_args)
ls_Headers = "Content-Length: " + String(ll_Length) + "~n~n"
//iinet_1.PostURL( ls_URL, lblob_args, ls_Headers, iir_Results1 )
iinet_1.GetURL( ls_URL, iir_Results1 )

filehnd = FileOpen("data.dat", LineMode!, Read!)
result = 0
do
result = fileread(filehnd,ls_text)
ll_pos = pos(ls_text,"date")
if ll_pos > 0 then
ls_text = mid(ls_text, ll_pos + 5,10)
sle_1.text = ls_text
end if
ll_pos = pos(ls_text,"EUR")
if ll_pos > 0 then
ls_text = mid(ls_text, ll_pos - 7,6)
if isnumber(ls_text) then
sle_2.text = ls_text + " EUR"
end if
end if

loop while Result <> -100
fileclose(filehnd)
ll_length = 0
end event

type sle_3 from singlelineedit within w_euros
integer x = 23
integer y = 24
integer width = 1422
integer height = 112
integer taborder = 70
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 8388608
string text = "www.bankofcanada.ca/rss/fx/noon/eurocae01.xml"
borderstyle borderstyle = stylelowered!
end type

--------------------------------

o si prefieres dame tu email y te envio la pbl directamente
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Recoger datos web

Publicado por Jorge (12 intervenciones) el 28/04/2011 16:14:02
Buenas, te paso mi email ya que no entiendo como importar ese código a una pbl.

"[email protected]"

Gracias por tu ayuda.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Recoger datos web

Publicado por Diego David (5 intervenciones) el 17/05/2013 07:44:41
Es justo lo que busco..
Por favor, me podría enviar el ejemplo a este correo: [email protected].
Te lo agradecería enormemente!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Recoger datos web

Publicado por Isaac Matal (8 intervenciones) el 16/08/2013 16:05:44
Hoy por la noche te compartiré el proyecto, para que lo descargues, en este momento no lo tengo a la mano
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
sin imagen de perfil

Recoger datos web

Publicado por Ytala Eusebio (4 intervenciones) el 26/11/2014 14:01:44
Porfavor yo también quiero que me lo envíes te lo agradecería un monton es de vida o muerte u.u .. mi correo es [email protected]
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Recoger datos web

Publicado por Isaac Matal (8 intervenciones) el 26/11/2014 15:31:48
te lo envío hoy por la noche, en este momento estoy en el trabajo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
sin imagen de perfil

Recoger datos web

Publicado por Ytala Eusebio (4 intervenciones) el 27/11/2014 19:37:24
Porfaaaa compartanlo u.u ... es muy urgente u.u
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Recoger datos web

Publicado por Ytala Eusebio Pinto (4 intervenciones) el 27/11/2014 20:13:26
ya logre importar el codigo que adjuntas pero al poner retrieve me muestra un mensaje y al aceptar me muestra la información hay alguna forma de que no salga ese mensaje??.

Saludos y Gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 24
Ha disminuido 1 puesto en Power Builder (en relación al último mes)
Gráfica de Power Builder

Recoger datos web

Publicado por guido (46 intervenciones) el 07/01/2017 15:25:25
Hola. Por favor pueden enviarme ese código a mi correo: [email protected]
Espero haya alguna otra forma y si la saben ayúdenme.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Recoger datos web

Publicado por David (71 intervenciones) el 02/08/2017 17:13:03
Saludos .
Tendras algún ejemplo de como capturar un archivo pdf (facturacion electronica) consumiendo el webservice
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Recoger datos web

Publicado por lus miguel sanchez o (1 intervención) el 27/11/2021 18:36:15
hola buenas tardes necesito ayuda con ese tema espero me podrias enviar a mi correo;
tengo una pagina de la cual quiero capturar el htm y de ese obtener algunos datos.
Gracias de antemano
Saludos desde Peru
este es mi correo [email protected]
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Recoger datos web

Publicado por Junior (1 intervención) el 06/07/2023 04:44:19
buenas noches podrías enviarme también el ejemplo a mi correo Gracias de antemano.
[email protected]
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar