【python】爬虫
反爬协议查看:baidu.com/robots.txt
# -*- coding:utf-8 -*-
# 爬虫:通过编写程序来获取到互联网上的资源
# 需求:用程序模拟浏览器,输入一个网址,从该网址中获取到资源或内容
from urllib.request import urlopen
url = "http://www.hao123.com"
resp = urlopen(url)
with open("myhao123.html", mode="w") as f:
f.write(resp.read().decode("utf-8")) # 拿到的是网页的源代码
print("over!")