Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Python

Idiom #101 Load from HTTP GET request into a string

Make an HTTP request with method GET to the URL u, then store the body of the response in the string s.

import requests
s = requests.get(u).content.decode()

installing requests library: pip install requests
import urllib.request
with urllib.request.urlopen(u) as f:
    s = f.read()
(def s (slurp u))

New implementation...