From: E. Pérez Herrero on
Hello everybody:

I=B4m trying to find the best way to test if any internet link is
available or not, something similar to FileExistsQ, but with a web
URL.

As I could not find anything about this topic on the documentation, I
=B4ve been rewieving some internal packages and the idea I had is this
one:

<< Utilities`URLTools`

(*This is a failed link *)
Quiet[If[(ToString[Head[Utilities`URLTools`FetchURL["http://
www.googeewrtwertwetrerle23232.es/", "file.tmp"]]] ==
"Symbol"), Print["Failed"], Print["Ok"]]];
(*And this is a good one*)
Quiet[If[(ToString[
Head[Utilities`URLTools`FetchURL["http://www.google.es/",
"file.tmp"]]] == "Symbol"), Print["Failed"], Print["Ok"]]]


The idea is to use the FecthURL function that cames within the
"URLTools" package, but this way of doing this seems awful and this
function creates a temporary file that after all it is necessary to be
deleted.

Does anybody knows the proper way to do this?

Thanks in advance.

Enrique.

From: Sjoerd C. de Vries on
Couldn't you just use Import? It can read from URLs and returns
$Failed when it can't.

Cheers -- Sjoerd

On Aug 8, 1:21 pm, E. P=E9rez Herrero <enriqueperezherr...(a)gmail.com>
wrote:
> Hello everybody:
>
> I=B4m trying to find the best way to test if any internet link is
> available or not, something similar to FileExistsQ, but with a web
> URL.
>
> As I could not find anything about this topic on the documentation, I
> =B4ve been rewieving some internal packages and the idea I had is this
> one:
>
> << Utilities`URLTools`
>
> (*This is a failed link *)
> Quiet[If[(ToString[Head[Utilities`URLTools`FetchURL["http://www.googeewrt=
wertwetrerle23232.es/", "file.tmp"]]] ==
> "Symbol"), Print["Failed"], Print["Ok"]]];
> (*And this is a good one*)
> Quiet[If[(ToString[
> Head[Utilities`URLTools`FetchURL["http://www.google.es/",
> "file.tmp"]]] == "Symbol"), Print["Failed"], Print["Ok"]]]
>
> The idea is to use the FecthURL function that cames within the
> "URLTools" package, but this way of doing this seems awful and this
> function creates a temporary file that after all it is necessary to be
> deleted.
>
> Does anybody knows the proper way to do this?
>
> Thanks in advance.
>
> Enrique.


From: Simon on
Hi,

maybe something like the following?

In[1]:=
ExistURLQ[site_String]:=Quiet[Check[Import[site,"Elements"];True,False,FetchURL::"conopen"],FetchURL::"conopen"]

In[2]:= ExistURLQ["http://www.google.com/"]
Out[2]= True

In[3]:= ExistURLQ["http://a.non.site/"]
Out[3]= False

In[4]:= Import["http://www.google.com/","Elements"]
Out[4]=
{Data,FullData,Hyperlinks,Images,ImageURLs,Plaintext,Source,Title,XMLObject}

Simon


On Aug 8, 9:21 pm, E. P=E9rez Herrero <enriqueperezherr...(a)gmail.com>
wrote:
> Hello everybody:
>
> I'm trying to find the best way to test if any internet link is
> available or not, something similar to FileExistsQ, but with a web
> URL.
>
> As I could not find anything about this topic on the documentation, I
> 've been rewieving some internal packages and the idea I had is this
> one:
>
> << Utilities`URLTools`
>
> (*This is a failed link *)
> Quiet[If[(ToString[Head[Utilities`URLTools`FetchURL["http://www.googeewrtwertwetrerle23232.es/", "file.tmp"]]] ==
> "Symbol"), Print["Failed"], Print["Ok"]]];
> (*And this is a good one*)
> Quiet[If[(ToString[
> Head[Utilities`URLTools`FetchURL["http://www.google.es/",
> "file.tmp"]]] == "Symbol"), Print["Failed"], Print["Ok"]]]
>
> The idea is to use the FecthURL function that cames within the
> "URLTools" package, but this way of doing this seems awful and this
> function creates a temporary file that after all it is necessary to be
> deleted.
>
> Does anybody knows the proper way to do this?
>
> Thanks in advance.
>
> Enrique.


From: E. Pérez Herrero on
On 9 ago, 11:11, Simon <simonjty...(a)gmail.com> wrote:
> Hi,
>
> maybe something like the following?
>
> In[1]:=
> ExistURLQ[site_String]:=Quiet[Check[Import[site,"Elements"];True,False,Fetc=ADhURL::"conopen"],FetchURL::"conopen"]
>
> In[2]:= ExistURLQ["http://www.google.com/"]
> Out[2]= True
>
> In[3]:= ExistURLQ["http://a.non.site/"]
> Out[3]= False
>
> In[4]:= Import["http://www.google.com/","Elements"]
> Out[4]=
> {Data,FullData,Hyperlinks,Images,ImageURLs,Plaintext,Source,Title,XMLObject=AD}
>
> Simon
>
> On Aug 8, 9:21 pm, E. P=E9rez Herrero <enriqueperezherr...(a)gmail.com>
> wrote:
>
>
>
> > Hello everybody:
>
> > I'm trying to find the best way to test if any internet link is
> > available or not, something similar to FileExistsQ, but with a web
> > URL.
>
> > As I could not find anything about this topic on the documentation, I
> > 've been rewieving some internal packages and the idea I had is this
> > one:
>
> > << Utilities`URLTools`
>
> > (*This is a failed link *)
> > Quiet[If[(ToString[Head[Utilities`URLTools`FetchURL["http://www.googeewrtwertwetrerle23232.es/", "file.tmp"]]] ==
> > "Symbol"), Print["Failed"], Print["Ok"]]];
> > (*And this is a good one*)
> > Quiet[If[(ToString[
> > Head[Utilities`URLTools`FetchURL["http://www.google.es/",
> > "file.tmp"]]] == "Symbol"), Print["Failed"], Print["Ok"]]]
>
> > The idea is to use the FecthURL function that cames within the
> > "URLTools" package, but this way of doing this seems awful and this
> > function creates a temporary file that after all it is necessary to be
> > deleted.
>
> > Does anybody knows the proper way to do this?
>
> > Thanks in advance.
>
> > Enrique.- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -

Simon I'm going to use your code, because it is better than mine.

Thank you all, but don't you think that Mathematica should include
this kind of function?

Thank you all

From: Sjoerd C. de Vries on
On Aug 10, 9:56 am, E. P=E9rez Herrero <enriqueperezherr...(a)gmail.com>
wrote:

> Thank you all, but don't you think that Mathematica should include
> this kind of function?
>

No, not necessarily. I don't think the Mathematica kernel should be
bloated will all kinds of functions. As you have seen, the function
could be written in one line of code and can be added easily if the
need arises.

Cheers -- Sjoerd