How do I Export[] hyperlinks that I've gotten from an Import[]?

In a Mathematica notebook, I enter and evaluation the following code, : url = “Alphabetical Listing—Wolfram Documentation”
fileName = “C:\Projects\Wolfram\AlphabeticalListing.txt”
links = Import[url, “Hyperlinks”]
lEx = Export[fileName, links]

The following is a partial example of what I get for output from the “links=” line above:

{“http://www.wolfram.com/”, “Wolfram Products & Services: Delivering Computation and Knowledge Technologies”,
“Wolfram Products & Services: Delivering Computation and Knowledge Technologies”,
“Wolfram Mathematica: Modern Technical Computing”,
“http://www.wolfram.com/solutions/education/students/”,
“Wolfram Mathematica Personal Edition”,
“Wolfram Player for Notebooks”, “Computable Document Format (CDF) for Interactive Content”,

A partial example of the output in the text file for the “lEx=” line above is:

{" Index of All New Functions ", {{“AbelianGroup”, “AllowedDimensions”, “Arg”}, {“Abort”, “AllowGroupClose”, “ArgMax”}, {“AbortKernels”, “AllowReverseGroupClose”, “ArgMin”}, {“AbortProtect”, “AlphaChannel”, “ARIMAProcess”},

Obviously, the two are not the same. How do I output to a text file, these hyperlinks from the Import[] line?

What version of Mathematica are you using? Your code works fine for me…

In[9]:= url = "http://reference.wolfram.com/mathematica/guide/AlphabeticalListing.html"


Out[9]= "http://reference.wolfram.com/mathematica/guide/AlphabeticalListing.html"


In[10]:= fileName = "/Users/dreiss/Desktop/AlphabeticalListing.txt"


Out[10]= "/Users/dreiss/Desktop/AlphabeticalListing.txt"


In[11]:= links = Import[url, "Hyperlinks"];


In[12]:= lEx = Export[fileName, links]




Out[12]= "/Users/dreiss/Desktop/AlphabeticalListing.txt"


In[13]:= FilePrint[%]


http://www.wolfram.com/
http://www.wolfram.com/products/
http://www.wolfram.com/products/
http://www.wolfram.com/mathematica/
http://www.wolfram.com/solutions/education/students/
http://www.wolfram.com/

(* truncating the output here...  *)

If you are using an earlier version of Mathematica than 9 and it’s having a hard time figuring out the export format, you might want to be more explicit by using

lEx = Export[fileName, links, "Lines"]

But what you are getting suggests to me that you had actually executed

links = Import[url, "Data"]

which would give the result that you got.

I hope this helps…

David, I entered your code in v10.2 (Windows 8.1) and got the same result as Baruch.

I just checked and it seems to work fine for me (V 10.2 Mac OSX). I also just fixed the unintended carriage return in (this is the correct version)

url = "http://reference.wolfram.com/mathematica/guide/AlphabeticalListing.html"

in my original post.

Perhaps a Wolfram person in this list can check whether there is a Windows vs Mac issue at play here.