Python 3:
import urllib.request
contents = urllib.request.urlopen("http://example.com/foo/bar").read()
Python 2:
import urllib2
contents = urllib2.urlopen("http://example.com/foo/bar").read()
Documentation for urllib.request
and read
.
More Related Contents:
- How to use Python to login to a webpage and retrieve cookies for later usage?
- How can I get the IP address from a NIC (network interface controller) in Python?
- How do I get Flask to run on port 80?
- How can I check if an ip is in a network in Python?
- Multiple ping script in Python
- Is there any way to do HTTP PUT in python
- Python urllib2 with keep alive
- Python socket receive – incoming packets always have a different size
- Python ‘requests’ library – define specific DNS?
- How to download a file using python in a ‘smarter’ way?
- How to encode UTF8 filename for HTTP headers? (Python, Django)
- Python urllib2 Progress Hook
- In Python, how do I decode GZIP encoding?
- How do I send a POST request as a JSON?
- Python send POST with header
- Using Flask, how do I modify the Cache-Control header for ALL output?
- python how to decode http response
- How to implement retry mechanism into python requests library?
- Test if an internet connection is present in python
- Python: How do I get key/value pairs from the BaseHTTPRequestHandler HTTP POST handler?
- Download file using partial download (HTTP)
- why is python string split() not splitting
- how to get access to error message from abort command when using custom error handler
- Get local network interface addresses using only proc?
- List of IP addresses/hostnames from local network in Python
- Unwanted RST TCP packet with Scapy
- How to send and receive HTTP POST requests in Python [closed]
- How to catch 404 error in urllib.urlretrieve
- Is there any way to do HTTP PUT request in Python?
- How do I set HTTP headers using Python’s urllib?