#!/usr/bin/env python
# _*_ coding:utf-8 _*_

import urllib2


#抓取 百度首页的数据
def load_baidu_data():

    # 1.URL
    url = "http://www.baidu.com"

    # 2.发送请求 -- 类文件对象
    response = urllib2.urlopen(url)
    # response = urllib2.urlopen("http://www.baidu.com")

    # 3.返回数据
    data = response.read()

    # print data

    return data


def  write_file(data):
    with open("1baidu.html","w") as f:
        f.write(data)

def index(request):
    pass

if __name__ == '__main__':

    data = load_baidu_data()
    write_file(data)
