python 实现简单爬虫
# 爬虫:爬去信息----模拟浏览
# 需求:用程序模拟浏览器,输入一个网址,从该网址获取到资源或者内容
# 用python特别简单
"""
1.
from urllib.request import urlopen
"""
from urllib.request import urlopen
url = "https://www.baidu.com"
# url = "https://www.freeaihub.com"
resp = urlopen(url)
print(resp.read().decode("utf-8"))
with open("mybaidu.html", mode="w") as f:
f.write(resp.read().decode("utf-8"))
print('over')