Archivo

Archivo para 18 noviembre 2010

Obtener codigo fuente de una pagina con PHP

noviembre 18, 2010 3 comentarios

Una pequeña funcion para obtener el codigo de una pagina.

function curl_get_file_contents($URL,$cookie){
   $c = curl_init();
   curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($c, CURLOPT_URL, $URL);
   curl_setopt($c, CURLOPT_COOKIE, $cookie);
   $contents = curl_exec($c);
   curl_close($c);
   //Valida si hay contenido sino retorna falso
   if ($contents) return $contents;
   else return false;
 }

Para llamarla

//Si la pagina no necesita alguna cookie
$fuente=curl_get_file_contents($url,null);

//Para paginas que necesiten alguna cookie por ejemplo aceptar un Disclaimer
$fuente=curl_get_file_contents($url,'Disclaimer=true;');

Categorías:php Etiquetas: , ,

Manipular fechas en Qt Jambi

noviembre 18, 2010 Deja un comentario

Transformar de QDate a Date


//Definimos el formato de fecha deseado
SimpleDateFormat formatoDelTexto = new SimpleDateFormat("yyyy-MM-dd");

//Transformamos la fecha QDate a ese formato
 fechaTexto = ui.datFechaNacimiento.date().toString("yyyy-MM-dd");

//Se setea al atributo del objeto
 empleado.setFechaNacimiento(formatoDelTexto.parse(fechaTexto));

Transformar de Date a QDate

//Transformamos la fecha Date a String
String fechaTexto2 = empleado.getFechaIngreso().toString();

//La dividimos por los guiones
String[] fecha2 = fechaTexto2.split("-");

//La seteamos al componente usando el constructor QDate
ui.datFechaIngreso.setDate(new QDate(Integer.parseInt(fecha2[0]),
                                     Integer.parseInt(fecha2[1]),
                                     Integer.parseInt(fecha2[2])));

Categorías:jambi, java, qt Etiquetas: , , , ,
Seguir

Get every new post delivered to your Inbox.