Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading File from website in Haskell

My sincere apologies if this question sounds silly or has already been asked; what is the standard way to read in a text file in the same sense that readFile does, except if the file is online?

I am of course given a URL as input, like the following example

https://dotnetperls-controls.googlecode.com/files/enable1.txt

What libraries do I import? Are there good references I can consult for this kind of web-based IO in Haskell?

*Please edit the tags as you see fit.

like image 520
dxuhuang Avatar asked Nov 26 '25 12:11

dxuhuang


1 Answers

This is a reproduction of @user2407038's comment, for the sake of having an answer.

import Network.HTTP

main = do
  response <- simpleHTTP $ getRequest "http://www.google.com/robots.txt"
  let body = fmap rspBody response
  print response
  print body
like image 171
Chris Taylor Avatar answered Nov 30 '25 16:11

Chris Taylor