MathGroup Archive 2010

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

Search the Archive

Re: ExistsURLQ

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111646] Re: ExistsURLQ
  • From: Simon <simonjtyler at gmail.com>
  • Date: Mon, 9 Aug 2010 05:11:51 -0400 (EDT)
  • References: <i3m3vp$hkt$1@smc.vnet.net>

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... 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.



  • Prev by Date: Re: Suggestions
  • Next by Date: Re: A new graphic user interface
  • Previous by thread: Re: ExistsURLQ
  • Next by thread: Re: ExistsURLQ