Python爬虫(2),Python3.x

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#中文注释
import urllib.request;


url = "http://www.baidu.com";
#头信息
user_agent="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0;";
headers ={'User-Agent':user_agent};
req = urllib.request.Request(url,headers=headers);
response = urllib.request.urlopen(req)
html = response.read()
print('loading...baidu');
print(html);

posted on 2016-09-02 22:54  愤怒的苹果ext  阅读(10)  评论(0编辑  收藏  举报

导航