Python urllib爬取百度首页,,官网下载安装pyth
Python urllib爬取百度首页,,官网下载安装pyth
官网下载安装python
在VS code里面安装python插件 https://www.cnblogs.com/bloglkl/archive/2016/08/23/5797805.html
/*没报错则证明urllib安装成功*/from urllib.request import urlopen直接在cmd输入
pip install beautifulsoup4//安装beautifulsoup4cmd进入python输入
/*没报错验证beautifulsoup4安装*/from bs4 import BeautifuSoup爬取百度首页
#!/usr/bin/env python# -*- coding:utf-8 -*-import io import sysfrom urllib import requestsys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding=‘utf8‘) #改变标准输出的默认编码 resp = request.urlopen("http://www.baidu.com/")print (resp.read().decode("utf-8"))
Python urllib爬取百度首页
评论关闭