硬核来袭!!!一篇文章教你入门Python爬虫网页解析神器——BeautifulSoup详细讲解

news2024/10/6 17:38:29

文章目录

  • 一、BeautifulSoup介绍
  • 二、安装
  • 三、bs4数据解析的原理
  • 四、bs4 常用的方法和属性
    • 1、BeautifulSoup构建
      • 1.1 通过字符串构建
      • 1.2 从文件加载
    • 2、BeautifulSoup四种对象
      • 2.1 Tag对象
      • 2.2 NavigableString对象
      • 2.3 BeautifulSoup对象
      • 2.4 Comment对象
  • 五、contents、children与descendants
  • 六、parent、parents
  • 七、next_sibling、previous_sibling
  • 八、 next_element、previous_element
  • 九、find()和find_all()
    • 9.1 方法
    • 9.2 tag名称
    • 9.3 属性
    • 9.4 正则表达式
    • 9.5 函数
    • 9.6 文本
  • 十、select()和select_one()
    • 10.1 通过tag选择
    • 10.2 id和class选择器
    • 10.3 属性选择器
    • 10.4 其他选择器
  • 十一、结合实战
  • 十二、CSS选择器
    • 12.1 常用选择器
    • 12.2 位置选择器
    • 12.3 其他选择器
  • 十三、使用总结

一、BeautifulSoup介绍

BeautifulSoup是一个可以从HTML或XML文件中提取数据的Python库。Beautiful Soup 已成为和 lxml、html5lib 一样出色的Python解释器,为用户灵活地提供不同的解析策略或强劲的速度。
BeautifulSoup官方文档:BeautifulSoup

二、安装

pip install bs4	   # 下载BeautifulSoup包
pip install lxml	# 下载lxml包

解析器的使用方法和优缺点比较

#标准库的使用方法
BeautifulSoup(html,'html.parser')
#优势:内置标准库,速度适中,文档容错能力强
#劣势:Python3.2版本前的文档容错能力差

#lxml HTML的使用方法
BeautifulSoup(html,'lxml')
#优势:速度快,文档容错能力强
#劣势:需要安装C语言库

#lxml XML的使用方法
BeautifulSoup(html,'xml')
#优势:速度快,唯一支持XML
#劣势:需要安装C语言库

#html5lib的使用方法
BeautifulSoup(html,'html5lib')
#优势:容错性最强,可生成HTML5
#劣势:运行慢,不依赖外部扩展

爬虫解析器汇总

解析器使用方法优势劣势
Python标准库BeautifulSoup(html, “html.parser”)内置标准库,速度适中,文档容错能力强Python3.2版本前的文档容错能力差
lxml HTML 解析器BeautifulSoup(html,‘lxml’)速度快,文档容错能力强需要安装C语言库
lxml XML解析器BeautifulSoup(markup, “xml”)速度快、唯一支持XML的解析器需要安装C语言库
html5libBeautifulSoup(html,‘html5lib’)容错性最强,可生成HTML5格式文档运行慢,不依赖外部扩展

三、bs4数据解析的原理

  1. 实例化一个BeautifulSoup对象,并且将页面源码数据加载到该对象中。
  2. 通过调用BeautifulSoup对象中相关的属性或者方法进行标签定位和数据提取。

四、bs4 常用的方法和属性

1、BeautifulSoup构建

1.1 通过字符串构建

from bs4 import BeautifulSoup

html = """
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div id="container">
  <span class="title">
    <h3>Python爬虫网页解析神器BeautifulSoup详细讲解</h3>
  </span>
</div>
</body>
</html>
"""

soup = BeautifulSoup(html, 'html.parser')
# 打印soup对象的内容,格式化输出
print(soup.prettify())

格式化打印html对象的内容,这个函数以后会经常用到。

1.2 从文件加载

from bs4 import BeautifulSoup

with open(r"D:\index.html") as fp:
    soup = BeautifulSoup(fp, "lxml")
print(soup.prettify())

2、BeautifulSoup四种对象

Beautiful Soup将复杂HTML文档转换成一个复杂的树形结构,每个节点都是Python对象,所有对象可以归纳为4种:Tag、NavigableString、BeautifulSoup、Comment

2.1 Tag对象

Tag对象又包括string、strings、stripped_strings
若一个节点只包含文本,可通过string直接访问该节点的文本,例如:

from bs4 import BeautifulSoup

html = """
<title>The Kevin's story house</title>
<span>这里是王菜鸟的Python系列文章</span>
<a href="https://token.blog.csdn.net/">王菜鸟的博客</a
"""
soup = BeautifulSoup(html, 'html.parser')
print(soup.title.text)
print(soup.span.text)
print(soup.a['href'])

# 输出结果
The Kevin's story house
这里是王菜鸟的Python系列文章
https://token.blog.csdn.net/

以上这种方式查找的是所有内容中第一个符合要求的标签,而对于Tag,它有两个重要的属性,nameattrs

print(soup.p.attrs)	# 此处获取的是p标签的所有属性,得到的类型是一个字典
print(soup.p['class'])	# 单独获取某个属性
print(soup.p.get('class'))	# 同上,单独获取某个属性

# 输出结果
{'class': ['link']}
['link']
['link']

对于这些属性和内容进行修改:

soup.p['class'] = "newClass"
print(soup)

# 输出结果
<title>The Kevin's story house</title>
<span>这里是王菜鸟的Python系列文章</span>
<p class="newClass">
<a href="https://token.blog.csdn.net/">王菜鸟的博客</a>
</p>

此外,还可以删除某个属性:

del soup.p['class']
print(soup)

# 输出结果
<title>The Kevin's story house</title>
<span>这里是王菜鸟的Python系列文章</span>
<p>
<a href="https://token.blog.csdn.net/">王菜鸟的博客</a>
</p>

tag.attrs是一个字典类型,可以通过tag.get('id')或者tag.get('class')两种方式,如果id或class属性不存在,则返回None。下标访问的方式可能会抛出异常KeyError。

其次可以使用get_text()获取文本节点

# 获取所有文本内容
soup.get_text()
# 可以指定不同节点之间的文本使用|分割。
soup.get_text("|")
# 可以指定去除空格
soup.get_text("|", strip=True)

2.2 NavigableString对象

若想获取标签里的内容,可以使用.string来获取

print(soup.a.string)
print(type(soup.a.string))

# 输出结果
王菜鸟的博客
<class 'bs4.element.NavigableString'>

2.3 BeautifulSoup对象

BeautifulSoup对象表示是一个文档的全部内容,大部分的时候可以把它当作一个Tag标签来使用,是一个特殊的Tag,可以分别来获取它的类型名称:

print(soup.name)
print(type(soup.name))
print(soup.attrs)

# 输出结果
[document]
<class 'str'>
{}

2.4 Comment对象

Comment对象是一个特殊类型的NavigableString对象,输出的内容仍然不包括注释符号。

五、contents、children与descendants

contents、children与descendants都是节点的子节点,不过

  • contents是列表
  • children是生成器

注意:contents、children只包含直接子节点,descendants也是一个生成器,不过包含节点的子孙节点。
子节点的举例:

from bs4 import BeautifulSoup

html = """
<html>
    <head>
        <title>The Dormouse's story</title>
    </head>
    <body>
        <p class="story">
            Once upon a time there were three little sisters; and their names were
            <a href="http://example.com/elsie" class="sister" id="link1">
                <span>Elsie</span>
            </a>
            <a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> 
            and
            <a href="http://example.com/tillie" class="sister" id="link3">Tillie</a>
            and they lived at the bottom of a well.
        </p>
        <p class="story">...</p>
"""

soup = BeautifulSoup(html, 'lxml')
print(soup.p.contents)
print(type(soup.p.contents))

# 输出结果
['\n            Once upon a time there were three little sisters; and their names were\n            ', <a class="sister" href="http://example.com/elsie" id="link1">
<span>Elsie</span>
</a>, '\n', <a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>, ' \n            and\n            ', <a class="sister" href="http://example.com/tillie" id="link3">Tillie</a>, '\n            and they lived at the bottom of a well.\n        ']
<class 'list'>

子孙节点的举例:

from bs4 import BeautifulSoup

html = """
<html>
    <head>
        <title>The Dormouse's story</title>
    </head>
    <body>
        <p class="story">
            Once upon a time there were three little sisters; and their names were
            <a href="http://example.com/elsie" class="sister" id="link1">
                <span>Elsie</span>
            </a>
            <a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> 
            and
            <a href="http://example.com/tillie" class="sister" id="link3">Tillie</a>
            and they lived at the bottom of a well.
        </p>
        <p class="story">...</p>
"""

soup = BeautifulSoup(html, 'lxml')
print(soup.p.descendants)
for i, child in enumerate(soup.p.descendants):
    print(i, child)

六、parent、parents

  • parent:父节点
  • parents:递归父节点
    父节点举例
from bs4 import BeautifulSoup

html = """
<html>
    <head>
        <title>The Dormouse's story</title>
    </head>
    <body>
        <p class="story">
            Once upon a time there were three little sisters; and their names were
            <a href="http://example.com/elsie" class="sister" id="link1">
                <span>Elsie</span>
            </a>
            <a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> 
            and
            <a href="http://example.com/tillie" class="sister" id="link3">Tillie</a>
            and they lived at the bottom of a well.
        </p>
        <p class="story">...</p>
"""

soup = BeautifulSoup(html, 'lxml')
print(soup.span.parent)

递归父节点举例

html = """
<html>
    <head>
        <title>The Dormouse's story</title>
    </head>
    <body>
        <p class="story">
            Once upon a time there were three little sisters; and their names were
            <a href="http://example.com/elsie" class="sister" id="link1">
                <span>Elsie</span>
            </a>
            <a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> 
            and
            <a href="http://example.com/tillie" class="sister" id="link3">Tillie</a>
            and they lived at the bottom of a well.
        </p>
        <p class="story">...</p>
"""
from bs4 import BeautifulSoup
soup = BeautifulSoup(html, 'lxml')
print(list(enumerate(soup.a.parents)))

七、next_sibling、previous_sibling

  • next_sibling:后一个兄弟节点
  • previous_sibling:前一个兄弟节点

兄弟节点举例

html = """
<html>
    <head>
        <title>The Dormouse's story</title>
    </head>
    <body>
        <p class="story">
            Once upon a time there were three little sisters; and their names were
            <a href="http://example.com/elsie" class="sister" id="link1">
                <span>Elsie</span>
            </a>
            <a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> 
            and
            <a href="http://example.com/tillie" class="sister" id="link3">Tillie</a>
            and they lived at the bottom of a well.
        </p>
        <p class="story">...</p>
"""
from bs4 import BeautifulSoup
soup = BeautifulSoup(html, 'lxml')
print(list(enumerate(soup.a.next_siblings)))
print(list(enumerate(soup.a.previous_siblings)))

八、 next_element、previous_element

next_element:后一个节点
previous_element:前一个节点
next_element与next_sibling的区别是:

  1. next_sibling从当前tag的结束标签开始解析
  2. next_element从当前tag的开始标签开始解析

九、find()和find_all()

9.1 方法

find_parent:查找父节点
find_parents:递归查找父节点
find_next_siblings:查找后面的兄弟节点
find_next_sibling:查找后面满足条件的第一个兄弟节点
find_all_next:查找后面所有节点
find_next:查找后面第一个满足条件的节点
find_all_previous:查找前面所有满足条件的节点
find_previous:查找前面第一个满足条件的节点

9.2 tag名称

# 查找所有p节点
soup.find_all('p')
# 查找title节点,不递归
soup.find_all("title", recursive=False)
# 查找p节点和span节点
soup.find_all(["p", "span"])
# 查找第一个a节点,和下面一个find等价
soup.find_all("a", limit=1)
soup.find('a')

9.3 属性

# 查找id为id1的节点
soup.find_all(id='id1')
# 查找name属性为tim的节点
soup.find_all(name="tim")
soup.find_all(attrs={"name": "tim"})
#查找class为clazz的p节点
soup.find_all("p", "clazz")
soup.find_all("p", class_="clazz")
soup.find_all("p", class_="body strikeout")

9.4 正则表达式

import re
# 查找与p开头的节点
soup.find_all(class_=re.compile("^p"))

9.5 函数

# 查找有class属性并且没有id属性的节点
soup.find_all(hasClassNoId)
def hasClassNoId(tag):
    return tag.has_attr('class') and not tag.has_attr('id')

9.6 文本

# 查找有class属性并且没有id属性的节点
soup.find_all(hasClassNoId)
def hasClassNoId(tag):
    return tag.has_attr('class') and not tag.has_attr('id')

十、select()和select_one()

select()是选择满足所有条件的元素,select_one()只选择满足条件的第一个元素。
select()的重点在于选择器上,CSS的选择器又分为id选择器class选择器,标签名不加任何修饰,类名前加点,id名前加#。在此使用类似的方法来筛选元素。

10.1 通过tag选择

通过tag选择非常简单,就是按层级,通过tag的名称使用空格分割就可以了。

# 选择title节点
soup.select("title")
# 选择body节点下的所有a节点
soup.select("body a")
# 选择html节点下的head节点下的title节点
soup.select("html head title")

10.2 id和class选择器

id和类选择器也比较简单,类选择器使用.开头,id选择器使用#开头。

# 选择类名为article的节点
soup.select(".article")
# 选择id为id1的a节点
soup.select("a#id1")
# 选择id为id1的节点
soup.select("#id1")
# 选择id为id1、id2的节点
soup.select("#id1,#id2")

10.3 属性选择器

# 选择有href属性的a节点
soup.select('a[href]')
# 选择href属性为http://mycollege.vip/tim的a节点
soup.select('a[href="http://mycollege.vip/tim"]')
# 选择href以http://mycollege.vip/开头的a节点
soup.select('a[href^="http://mycollege.vip/"]')
# 选择href以png结尾的a节点
soup.select('a[href$="png"]')
# 选择href属性包含china的a节点
soup.select('a[href*="china"]')
# 选择href属性包含china的a节点
soup.select("a[href~=china]")

10.4 其他选择器

# 父节点为div节点的p节点
soup.select("div > p")
# 节点之前有div节点的p节点
soup.select("div + p")
# p节点之后的ul节点(p和ul有共同父节点)
soup.select("p~ul")
# 父节点中的第3个p节点
soup.select("p:nth-of-type(3)")

十一、结合实战

通过一个案例,来学习find()、find_all()、select()、select_one()的用法。

from bs4 import BeautifulSoup

text = '''
<li class="subject-item">
    <div class="pic">
      <a class="nbg" href="https://mycollege.vip/subject/25862578/">
        <img class="" src="https://mycollege.vip/s27264181.jpg" width="90">
      </a>
    </div>
    <div class="info">
      <h2 class=""><a href="https://mycollege.vip/subject/25862578/" title="解忧杂货店">解忧杂货店</a></h2>
      <div class="pub">[日] 东野圭吾 / 李盈春 / 南海出版公司 / 2014-5 / 39.50元</div>
      <div class="star clearfix">
        <span class="allstar45"></span>
        <span class="rating_nums">8.5</span>
        <span class="pl">
            (537322人评价)
        </span>
      </div>
      <p>现代人内心流失的东西,这家杂货店能帮你找回——僻静的街道旁有一家杂货店,只要写下烦恼投进卷帘门的投信口,
      第二天就会在店后的牛奶箱里得到回答。因男友身患绝... </p>
    </div>
</li>
'''

soup = BeautifulSoup(text, 'lxml')

print(soup.select_one("a.nbg").get("href"))
print(soup.find("img").get("src"))
title = soup.select_one("h2 a")
print(title.get("href"))
print(title.get("title"))

print(soup.find("div", class_="pub").string)
print(soup.find("span", class_="rating_nums").string)
print(soup.find("span", class_="pl").string.strip())
print(soup.find("p").string)

十二、CSS选择器

12.1 常用选择器

https://img-blog.csdnimg.cn/20191030084013872.png

12.2 位置选择器

在这里插入图片描述

12.3 其他选择器

在这里插入图片描述

十三、使用总结

  • 推荐使用lxml解析库,必要时使用html.parser
  • 标签选择筛选功能弱但是速度快
  • 建议使用find()find_all() 查询匹配单个结果或者多个结果
  • 如果对CSS选择器熟悉建议使用select()select_one()
  • 记住常用的获取属性和文本值的方法

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/179584.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

springboot自定义拦截器的简单使用和一个小例子

springboot自定义拦截器的使用1. 自定义拦截器2. 拦截器登录验证的小demo2.1 配置pom.xml2.2 创建User的bean组件2.3 创建需要的表单页面以及登录成功的页面2.4 编写controller映射关系2.5 自定义拦截器类&#xff0c;实现intercepetor接口2.6注册添加拦截器&#xff0c;自定义…

【SpringCloud】Nacos集群搭建

集群结构图官方给出的Nacos集群图如下&#xff1a;其中包含3个nacos节点&#xff0c;然后一个负载均衡器代理3个Nacos。这里负载均衡器可以使用nginx。我们接下来要尝试 Nacos集群搭建&#xff0c;效果图如下所示&#xff1a;三个nacos节点的地址&#xff1a;节点ipportnacos1l…

二、Java框架之Spring注解开发

文章目录1. IOC/DI注解开发1.1 Component注解ComponentController Service Repository1.2 纯注解开发模式1.3 注解开发bean管理ScopePostConstruct PreDestroy1.4 注解开发依赖注入Autowired QualifierValuePropertySource1.5 第三方bean管理Beanimport&#xff08;多个Config类…

Redisson 完成分布式锁

1、简介 Redisson 是架设在 Redis 基础上的一个 Java 驻内存数据网格&#xff08;In-Memory Data Grid&#xff09;。充分 的利用了 Redis 键值数据库提供的一系列优势&#xff0c;基于 Java 实用工具包中常用接口&#xff0c;为使用者 提供了一系列具有分布式特性的常用工具类…

JavaWeb | 揭开SQL注入问题的神秘面纱

本专栏主要是记录学习完JavaSE后学习JavaWeb部分的一些知识点总结以及遇到的一些问题等&#xff0c;如果刚开始学习Java的小伙伴可以点击下方连接查看专栏 本专栏地址&#xff1a;&#x1f525;JDBC Java入门篇&#xff1a; &#x1f525;Java基础学习篇 Java进阶学习篇&#x…

MyEclipse提示过期,MyEclipse Subscription Expired解决方案

一、错误描述 某一天打开MyEclipse&#xff0c;突然发现出现如下提示框&#xff1a; 1.错误日志 Thank you for choosing MyEclipse Your license expired 1091 days ago. To continue use of MyEclipse please choose "Buy" to purchase a MyEclipse license. I…

离散系统的数字PID控制仿真-3

离散PID控制的封装界面如图1所示&#xff0c;在该界面中可设定PID的三个系数、采样时间及控制输入的上下界。仿真结果如图2所示。图1 离散PID控制的封装界面图2 阶跃响应结果仿真图&#xff1a;离散PID控制的比例、积分和微分三项分别由Simulink模块实现。离散PID控制器仿真图&…

【servlet篇】servlet相关类介绍

目录 servlet对象什么时候被创建&#xff1f; 2.servlet接口中各个方法的作用 3.相关类和接口介绍 GenericServlet ServletConfig ServletContext HttpServlet servlet对象什么时候被创建&#xff1f; 1&#xff0c;通常情况下&#xff0c;tomcat启动时&#xff0c;并没有…

高阶数据结构 位图的介绍

作者&#xff1a;学习同学 专栏&#xff1a;数据结构进阶 作者简介&#xff1a;大二学生 希望能和大家一起进步&#xff01; 本篇博客简介&#xff1a;简单介绍高阶数据结构位图 位图的介绍bitset的介绍位图的引入位图的概念位图的引用bitset的使用bitset定义方式方式一 默认初…

基于BGP技术和防火墙双机热备技术的校园网设计与实现

规划设计描述网络拓扑设计分为三部分进行设计&#xff1a;主校区网络、 运营商骨干网络、分校区网络。总公司网络设计&#xff1a;划分&#xff1a;教学楼区域、宿舍区域、办公楼区域、行政楼区域&#xff0c;图书馆区域、数据中心。并且设有web服务器。出口设置双机热备技术&a…

人工智能在网络犯罪中的应用:5个最重要的趋势

在当今的数字世界中&#xff0c;网络威胁不断演变。 人工智能的使用虽然在网络犯罪中还不是必须的&#xff0c;但无疑是我们将在未来几年看到的具有重大发展的最有前途的技术之一。 随着 AI 技术的进步&#xff0c;攻击者开始尝试新的、越来越复杂和有效的攻击模式和技术。 …

PCL OcTree(二)——点云压缩

文章目录 一、应用背景二、代码解读1、官方源码2、代码解释与扩展3、完整代码三、参考文献一、应用背景 点云由庞大的数据集组成,这些数据集通过距离、颜色、法线等附加信息来描述空间三维点。此外,点云能以非常高的速率被创建出来,因此需要占用相当大的存储资源,一旦点云…

【信管9.3】项目干系人管理

项目干系人管理干系人&#xff0c;这三个字我们已经很早就见过了&#xff0c;相信你对它一定不会陌生。在我们的教材中&#xff0c;它是和项目沟通管理放在一起的&#xff0c;在同一个章节中讲完了&#xff0c;我们也遵循教材的顺序&#xff0c;将它和沟通放在一起。其实&#…

【计算机网络(考研版)】第一站:计算机网络概述(二)

目录 四、OSI参考模型和TCP/IP模型 1.ISO/0SI参考模型 2.TCP/IP模型 3.OSI/RM参考模型和TCP/IP参考模型的区别和联系 4.五层教学模型 5.数据流动示意图 四、OSI参考模型和TCP/IP模型 前面我们已经讨论了体系结构的基木概念&#xff0c;在具体的实施中有两个重要的网络体系…

Qt扫盲-QNetworkReply理论总结

QNetworkReply理论总结一、概述二、使用1. 读取body内容2. 获取head属性值3. 错误处理一、概述 QNetworkReply类包含了与QNetworkAccessManager发送的请求回来的相关的数据和元数据。与QNetworkRequest类似&#xff0c;它包含一个URL和头部(包括解析的和原始的形式)&#xff0…

Java基础语法——运算符与表达式

目录 Eclipse下载 安装 使用 运算符 键盘录入 Eclipse下载 安装 使用 Eclipse的概述(磨刀不误砍柴工)——是一个IDE(集成开发环境)Eclipse的特点描述&#xff08;1&#xff09;免费 &#xff08;2&#xff09;纯Java语言编写 &#xff08;3&#xff09;免安装 &#xff08…

【自然语言处理】情感分析(二):基于 scikit-learn 的 Naive Bayes 实现

情感分析&#xff08;二&#xff09;&#xff1a;基于 scikit-learn 的 Naive Bayes 实现在上一篇博客 情感分析&#xff08;一&#xff09;&#xff1a;基于 NLTK 的 Naive Bayes 实现 中&#xff0c;我们介绍了基于 NLTK 实现朴素贝叶斯分类的方法&#xff0c;本文将基于 sci…

阿里云效git仓库的创建与使用

一、为何选用阿里仓库为什么要让同学们什么阿里云git仓库呢&#xff1f;主要是考虑速度、容量、人数限制、功能等因素。阿里的速度较快。代码库不限&#xff0c;人数不限制。gitee等仓库要求人员在5名以下&#xff0c;不方便实操练习。云效的功能还强大。有阿里做后盾&#xff…

微服务必经之路,企业应用架构蓝图,有状态和无状态组件之分

微服务如火如荼&#xff0c;但很多时候是事倍功半&#xff0c;花了大力气&#xff0c;收获很少。怎样实现一键扩展&#xff0c;负载量自然伸缩&#xff0c;高可用呢&#xff1f; 一般公司都有了企业级的应用&#xff0c;我们通常所说的三层架构&#xff0c;即用户界面或者说前台…

“华为杯”研究生数学建模竞赛2005年-【华为杯】D题:仓库容量有限条件下的随机存贮管理问题(附获奖论文和matlab代码)

赛题描述 工厂生产需定期地定购各种原料,商家销售要成批地购进各种商品。无论是原料或商品,都有一个怎样存贮的问题。存得少了无法满足需求,影响利润;存得太多,存贮费用就高。因此说存贮管理是降低成本、提高经济效益的有效途径和方法。 问题2 以下是来自某个大型超市的…