官网下载安装python
在VS code里面安装python插件 https://www.cnblogs.com/bloglkl/archive/2016/08/23/5797805.html

  • cmd进入python输入
/*
没报错则证明urllib安装成功
*/
from urllib.request  import urlopen
  • 直接在cmd输入
pip install beautifulsoup4//安装beautifulsoup4
  • cmd进入python输入
/*
没报错验证beautifulsoup4安装
*/
from bs4 import BeautifuSoup
  • 爬取百度首页
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import io  
import sys
from urllib import request
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') #改变标准输出的默认编码  
resp = request.urlopen("http://www.baidu.com/")
print (resp.read().decode("utf-8"))

Python urllib爬取百度首页

相关文章:

  • 2022-12-23
  • 2021-10-22
  • 2021-10-07
  • 2021-06-15
  • 2022-12-23
  • 2021-12-07
  • 2022-01-14
猜你喜欢
  • 2021-06-04
  • 2021-11-12
  • 2021-08-21
  • 2022-01-22
  • 2021-06-02
  • 2021-05-03
相关资源
相似解决方案