1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| public class AllocineSearch{
/*This class aims to dl from Allocine details from movies*/
/* TODO =>fonction which allows to search in the series DB*/
String path;
URL u;
public AllocineSearch(String path)
{/*Constructor*/
this.path=path;
try {
u=new URL(path);
System.out.println("URL "+this.path+" valide");
} catch (MalformedURLException e) {
System.out.println("URL "+this.path+" Non valide");
}
}
String read_str() throws IOException
{
int b;
InputStream is = u.openStream();
String s = null;
while ((b = is.read()) != -1)
s+=(char) b; /*while*/
//EOF reached
is.close();
int beginning=s.indexOf("Recherche : ");
int ending =s.indexOf("Articles");
/*Gives the integer on which the Sequence begins with*/
String res = null ;
for(int i=beginning;i<ending;i++)
{
res+=s.charAt(i);
}
return res;
}/*read_str*/
boolean isIn(String form)
{
int beginning=form.indexOf("Recherche : "); /*Returns the int on which begins this sequence*/
int index = form.indexOf("Pas de résultats", beginning);
return (index!=-1);/*indexOf returns -1 if not found*/
} |
Partager