If you try to request a URL through some external tool, such as wget , you will see that Wikipedia does not directly process the results page. It actually returns a 302 Moved Temporarily redirect.
Entering this URL in the browser will be fine, as the browser will automatically redirect. simpleHTTP , however, will not. simpleHTTP , as the name suggests, is pretty simple. It does not handle things like cookies, SSL, or redirects.
Instead, you will want to use Network.Browser . It offers much more control over query execution. In particular, the setAllowRedirects function setAllowRedirects force it to automatically follow forwarding.
Here is a quick and dirty function for loading a URL into a String with redirection support:
import Network.Browser grabUrl :: String -> IO String grabUrl url = fmap (rspBody . snd) . browse $ do -- Disable logging output setErrHandler $ const (return ()) setOutHandler $ const (return ()) setAllowRedirects True request $ getRequest url
source share