我们要用到 requests 模块
这个是干啥的呢?
这个模块可以发送网络请求(Get,Post,Delete… …)
我们通过这个模块进行Http Get 请求,这样就可以拿到网页了。
我们要使用这个模块就要用pip来安装:

python -m pip install requests

安装完成后我们就可以上代码了(不多说):

# -*- coding: UTF-8 -*-
import requests  # 导入requests包

url = "https://www.csdn.net";  # 需要请求的网址
html_str = requests.get(url)  # 发送Get请求
print(html_str.text)  # 得到结果并输出Text属性的值,得到网页的内容

运行结果如下:
Python小白爬虫(一) _使用requests模块进行Get请求网页得到页面内容

相关文章:

  • 2022-12-23
  • 2021-11-01
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
  • 2021-09-19
  • 2022-01-18
猜你喜欢
  • 2022-12-23
  • 2021-06-16
  • 2022-12-23
  • 2021-12-07
  • 2021-07-13
  • 2021-10-25
  • 2022-12-23
相关资源
相似解决方案