Hacker News new | past | comments | ask | show | jobs | submit login

Or even just urllib?

     import urllib

     foo = urllib.urlopen("http://gun.io).read()
     print foo
I mean...maybe urllib (or urllib2) are old and unhip at this point, but they're heavily documented.

I use urllib all over my projects and have never encountered any problems.




In fact, it's even better than what the author said:

  import requests
  print requests.get('http://gun.io').content
Only two lines!


Well...urllib is the same

    import urllib
    print urllib.urlopen('http://gun.io').read()
And to be clear, you'd really never want to just print the content like that. You'd be doing something like.

     import urllib
     import simplejson

     req = urllib.urlopen("https://graph.facebook.com/some_id")
     response = req.read()

     json_data = simplejson.loads(response)
(Python is syntactically pretty, imho)


    import requests; print requests.get('http://gun.io').content
my god, python is cloud scale.


In one statement:

    print __import__('requests').get('http://gun.io').content


+1




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: