I have Mathematica code that uses Import[] to download URLs. I noticed that first time I use the Import[] command it works. Next time it fails. I'm using Windows 7, Mathematica 8.0.4.
Here is an example. I start new sesssion of Mathematica, and then type
Import["http://groups.google.com/group/comp.soft-sys.math.mathematica/about"]
No problem. Now I issue the same command again on the same URL (or different one)
Import["http://groups.google.com/group/comp.soft-sys.math.mathematica/about"]
and now this gives me an error
FetchURL::conopen: The connection to URL http://groups.google.com/group/comp.soft-sys.math.mathematica/about cannot be opened. If the URL is correct, you might need to configure your firewall program, or you might need to set a proxy in the Internet connectivity tab of the Preferences dialog (or by calling SetInternetProxy). For HTTPS connections, you might need to inspect the authenticity of the server's SSL certificate and choose to accept it.
On the same Windows 7 PC, I start MATLAB, and type
data=urlread('http://groups.google.com/group/comp.soft-sys.math.mathematica/about')
data=urlread('http://groups.google.com/group/comp.soft-sys.math.mathematica/about')
and both work. I get the page fine the second time around.
I open the browser, and type the URL, and I can see the page. This is the same PC. No proxy. home PC. Nothing special.
P.S. This code used to work fine with Mathematica on an earlier version (forgot which one now), becuase I used Mathematica to generate this web page
and all the Import commands I used are listed above and you can see them. I have list of many URL's that I loop over calling Import[] on them one by one.
Again, the problem is that I now get an error on a URL using Import[] and the problem seems to show up the second time I use the Import[]. Any suggestions how to fix this? Is this a known issue?
update I still have Mathematica 7 and 6 installed. So I tried this on them. And I get the same problem there. This is strange, since this code worked before. I think now it is a google groups/server problem, becuase when I try different domain (i.e. not google groups), I do not get this problem
data = Import["http://www.yahoo.com", "Data"];
data = Import["http://www.yahoo.com", "Data"];
No error in the second time.
I do not understand why this problem (i.e. using the Import command again) gives an error on some URLs and not on others.
update
Thanks for everyone's help and for WReach solution. I have used WReach nice solution to bypass the problem and have just updated the currrent Mathematica code I was using to update the usenet programming languages trends charts. The updated charts are on this page if you are interested in seeing the result.
Importthen waiting for few minutes or more, and issuing it again, it still fails. Only when restarting the kernel fixes things. So there is some state internally in the kernel that is being remembered (may be some counter or so). i.e. it is not because many calls are being send one after the other very fast that is causing Google to reject the second call. I need to find a work around, and I might have to use some other program to do this. Thanks for your suggestion. – Nasser Oct 30 '12 at 15:27