MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: ExistsURLQ

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111682] Re: ExistsURLQ
  • From: E. Pérez Herrero <enriqueperezherrero at gmail.com>
  • Date: Tue, 10 Aug 2010 03:55:27 -0400 (EDT)
  • References: <i3m3vp$hkt$1@smc.vnet.net> <i3ogoe$ovm$1@smc.vnet.net>

On 9 ago, 11:11, Simon <simonjty... at 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... at 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


  • Prev by Date: Re: remote kernel problem
  • Next by Date: Re: A new graphic user interface
  • Previous by thread: Re: ExistsURLQ
  • Next by thread: Re: ExistsURLQ