forked from epequeno/python-for-informatics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03.py
More file actions
26 lines (19 loc) · 619 Bytes
/
03.py
File metadata and controls
26 lines (19 loc) · 619 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 24 16:11:41 2014
@author: Estevan Adrian Pequeno
"""
'''
Use urllib to replicate the previous exercise of (1) retrieving the document
from a URL, (2) displaying up to 3000 characters, and (3) counting the
overall number of characters in the document. Don't worry about the headers
for this exercise, simply show the first 3000 characters of the document
contents.
'''
'''
I'm going to use requests instead http://docs.python-requests.org/en/latest/
'''
import requests
content = requests.get('http://www.py4inf.com').content
print content[:3000]
print len(content)