salut ,
je essayer de récupérer le code source d'une page web à partir de son URL.
j'ai un code qui le fait avec Java mais j'ai besion en PHP .....
voila le code en java et si qlq peut me l'envoyer en PHP.......Merci
--------------------------------------------------------------------
public static String getIpFrom(String adresse) {
String toreturn = null;
try {
// creation d'un objet URL
URL url = new URL(adresse);
// on etablie une connection a cette url
URLConnection uc = url.openConnection();
// on y cree un flux de lecture
InputStream in = uc.getInputStream();
// on lit le premier bit
int c = in.read();
// on cree un StringBuilder pour par la suite y ajouter tout les bit lus
StringBuilder build = new StringBuilder();
// tant que c n'est pas egale au bit indiquant la fin d'un flux...
while (c != -1) {
build.append((char) c);
// ...on l'ajoute dasn le StringBuilder...
c = in.read();
// ...on lit le suivant
}
// on retourne le code de la page
toreturn = build.toString();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return toreturn;
}
----------------------------------------------------------------------

show_source ( "../repertoire/sousrepertoire/fichier.php" );
?>
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package experience01;
/**
*
* @author redpoint
*/
//the PCA class get on the input the of constructor a 2 dimension array where the
//rows are the variables and the columns
//are the observations
public class PCA{
float data[][];
float mean[];
float covariance[][];
float eig_vec[][],eig_val[],pca[][];
int k;
public PCA(float data[][]){
this.data=data;
mean=new float[data[0].length];
k=this.data.length;
init();
}
public PCA(float data[][],int dim){
this.data=data;
mean=new float[data[0].length];
k=dim;
init();
}
public void init(){
//get the mean vector
for(int i=0;i<data[0].length;i++){
float x=0;
for(int j=0;j<data.length;j++){
x+=data[j][i];
}
x/=data.length;
mean[i]=x;
}
//adjust the data set
for(int i=0;i<data.length;i++){
for(int j=0;j<data[0].length;j++){
data[i][j]-=mean[j];
}
}
//compute the covariance matrix
covariance=Stat.getCovarianceMatrix(data);
//get the eigenvectors and eigenvalues of the covariance matrix
Eigen eig=new Eigen(covariance);
eig_vec=eig.getEigenVectors();
eig_val=eig.getEigenValues();
getFeatureVector();
//get the final data
pca=Matrice.getMultiplicate(Matrice.getTranspose(eig_vec),data);
}
public float[][] getPcaData(){
return pca;
}
public float[][] getAdjustedData(){
return data;
}
public float[] getMeanVector(){
return mean;
}
public float[][] getCovarianceMatrix(){
return covariance;
}
public float[][] getEigenVectors(){
return eig_vec;
}
public float[] getEigenValues(){
return eig_val;
}
public float[][] getOriginalDataAdjuste(float featureRow[][],float pcaData[][]){
return Matrice.getMultiplicate(featureRow,pcaData);
}
public float[][] getOriginalData(float featureRow[][],float pcaData[][],float mean_vec[]){
float result[][]=Matrice.getMultiplicate(featureRow,pcaData);
for(int i=0;i<result.length;i++)
for(int j=0;j<result[0].length;j++)
result[i][j]+=mean_vec[j];
return result;
}
//re-order the eigen values/vectors arrays.
public void getFeatureVector(){
for(int j=0;j<eig_val.length;j++){
int max=j;
for(int i=j;i<eig_val.length;i++){
if(eig_val[max]<eig_val[i]){
max=i;
}
}
if(max!=j){
float temp;
temp=eig_val[max];
eig_val[max]=eig_val[j];
eig_val[j]=temp;
for(int i=0;i<eig_vec.length;i++){
temp=eig_vec[i][max];
eig_vec[i][max]=eig_vec[i][j];
eig_vec[i][j]=temp;
}
}
}
if(k<eig_vec[0].length){
float temp[][]=new float[eig_vec.length][k];
float temp_val[]=new float[k];
for(int i=0;i<temp.length;i++){
for(int j=0;j<k;j++){
temp[i][j]=eig_vec[i][j];
}
}
for(int i=0;i<temp_val.length;i++)
temp_val[i]=eig_val[i];
eig_val=temp_val;
eig_vec=temp;
}
}