您的位置:首页 > 编程语言 > Python开发

Python爬虫(2),Python3.x

2016-09-02 22:54 357 查看
#!/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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: