Python如何使用Beautifulsoup库实现同样功能?(读取HTML上的分级列表)
Python如何使用Beautifulsoup库实现同样功能?(读取HTML上的分级列表)import re
def fixdesc(fileDesc):
pattern = r'[\r\n\t]+'# 过滤科学文库页面上格式化产生的换行符等
fileDesc = re.sub(pattern, "", fileDesc)
return fileDesc.replace('<br/>', '').replace('<br/', '').replace('<br', '').replace('<b', '')
resp='''
<div style="background-color: #313d4f">
<div class="com_width1200">
<div class="container">
<div class="header_top row">
<div class="col-md-4 col-xs-12 head_top_div">
<div class="row">
<div class="col-md-3 col-xs-12">
<span id="userIp">82.157.123.54</span>
<input type="hidden" class="user_ip_hidden" value="82.157.123.54" />
</div>
<div class="col-md-9col-xs-12">
<span id="org_name"><span></span></span>
</div>
</div>
</div>
<div class="col-md-3col-xs-12 head_top_div" style="text-align:center;">
<!--<span class="online" style="display:none;"><a href="/shop/book/News/detail.do" style="color:#ffff00;font-size:16px;"><i class="fa fa-bell-o"></i>科学文库有奖问答活动</a></span>-->
<span><a href="https://mp.weixin.qq.com/s/QGkXz3bYp_nFK6y2SdolEA" style="color:#ffff00;"><i class="fa fa-bell-o"></i> 校外访问科学出版社系列数据库的方法</a></span>
<!--<span style="display:none;"><a href="javascript:;"><i class="fa fa-bell-o"></i>2020科学文库有奖问答活动</a></span>-->
</div>
<div class="col-md-5 text-rightcol-xs-12 head_top_div">
<!-- <img src="/kxwk5_style/images/avatar.png" class="img-circle" style="width: 30px"> -->
<a id="register" href="/shop/member/Member/create.do"><span class="">注册</span></a>
<a id="example" href="/shop/main/Login/ssoLogin.do"><span class="margin_left_side index_about_us">登录</span></a>
<!--<span id="example" data-toggle="modal" data-target="#loginModal" class="margin_left_side index_about_us pointer_link login_btn_modal">登录</span>-->
<a id="userName" href="/shop/member/Member/show.do" title="个人中心"><span class="margin_left_side"></span></a>
<img title="退出" id="logoutShow" class="margin_left_side index_about_us pointer_link" src="/kxwk5_style/images/sign_out.png">
<!--<span class="index_about_us pointer_link"><a href="/shop/announcement1.html">重要公告 </a></span>-->
<span class="index_about_us pointer_link"><a href="/shop/helpCenter1.html">关于我们 </a></span>
<!--<span class=""><a href="http://159.226.29.161/shop/main/Login/shopFrame.do">旧版入口 </a></span>-->
</div>
</div>
</div>
</div>
</div>
<div style="background-color: #ffffff">
<div class="com_width1200">
<div class="container">
<div class="header_bottom row">
<div class="col-md-4 head_bottom_div">
<a href="/" target="_parent"><img src="/kxwk5_style/images/index_logo.png"></a>
</div>
<div class="col-md-6 col-md-offset-2 text-right head_bottom_div">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-7 col-md-offset-2">
<div class="input-group">
<div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle search_btn_checkbox" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="index_serch_type">关键字</span><span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a class="search_type" data-type="关键字" href="#">关键字</a></li>
<li><a class="search_type" data-type="全文" href="#">全文</a></li>
</ul>
</div>
<form method="post" id="searchform" action="/shop/book/Booksimple/list.do">
<input name="showQueryModel.nameIsbnAuthor" type="text" class="form-control search_btn_serachbox" aria-label="..." placeholder="在全库检索">
<span class="input-group-btn">
<button class="btn btn-default search_btn" type="button">搜索</button>
</span><span class="input-group-btn"></span>
</form>
</div>
</div>
<div class="col-lg-2 col-md-3 bottom_pro_search">
<a href="/shop/main/Login/advancedSearch.do" target="_parent"><span>高级搜索</span></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="block_for_scroll"></div>
<div style="background-color: #163273" id="nav_container">
<div class="com_width1200">
<div class="container">
<div class="row nav_container" id="nav_container">
<div id="xialamenu" class="col-md-2 col-sm-4 col-xs-5" style="padding-top: 14px;">
<ul class="sub">
<li id="showdiv">
<img src="/kxwk5_style/images/index_dropdown.png" style="cursor: pointer;margin-top: -1px">
<span class="showdiv">中图分类</span>
<div id="nav" style="display:none;" class="wrap">
<ul class="all-sort-list tit" style="margin:0; padding:0">
<li class="item mod_cate">
<h2><i class="arrow_dot fr"></i><a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6093">文学</a>
</h2>
<div class="item-list clearfix mod_subcate">
<div class="subitem mod_subcate_main">
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6094'">文学理论
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6107">文学创作论</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6114">各体文学理论和创作方...</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6125">文学评论、文学欣赏</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6126'">世界文学
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6127">作品评论和研究</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6145">作品集</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6156'">中国文学
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6158">文学评论和研究</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6164">各体文学评论和研究</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6206">文学史、文学思想史</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6208">作品集</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6228">诗歌、韵文</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6310">小说</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6328">报告文学</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6340">散文</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6371">儿童文学</a>
</dd>
</dl>
</div>
</div>
</li>
<li class="item mod_cate">
<h2><i class="arrow_dot fr"></i><a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6397">艺术</a>
</h2>
<div class="item-list clearfix mod_subcate">
<div class="subitem mod_subcate_main">
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6398'">艺术理论
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6401">艺术与其他科学的关系</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6402">艺术美学</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6416">造型艺术理论</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6422'">世界各国艺术概况
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6432">中国艺术</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6440">宗教艺术</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6441'">绘画
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6444">绘画理论</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6459">绘画技法</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6500">中国绘画作品</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6516">各国绘画作品</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6529'">书法、篆刻
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6530">中国书法、篆刻</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6559">外文书法</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6560'">雕塑
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6572">雕塑技法</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6598">中国雕塑作品</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6618'">摄影艺术
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6619">摄影艺术理论</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6629">各种摄影艺术</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6649'">工艺美术
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6661">图案学</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6662">中国工艺美术</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6711">各国工艺美术</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6713'">音乐
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6714">音乐理论</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6730">音乐技术理论与方法</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6784">器乐理论与演奏法</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6830">民族器乐理论和演奏法</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=6867">中国音乐作品</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7053'">舞蹈
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7054">舞蹈理论</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7147'">戏剧艺术
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7148">戏剧艺术理论</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7164">舞台艺术</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7190">中国戏剧艺术</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7233'">电影、电视艺术
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7234">电影、电视艺术理论</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7246">电影、电视艺术与技术</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7264">电影、电视拍摄艺术与...</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7272">电影、电视企业组织与...</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7286">各种电影、电视:按内...</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7338">电影、电视事业</a>
</dd>
</dl>
</div>
</div>
</li>
<li class="item mod_cate">
<h2><i class="arrow_dot fr"></i><a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7354">历史、地理</a>
</h2>
<div class="item-list clearfix mod_subcate">
<div class="subitem mod_subcate_main">
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7355'">史学理论
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7357">社会发展理论</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7361">历史研究</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7365">史学史</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7369'">世界史
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7370">通史</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7381">古代史(公元前40世...</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7393">近代史(1640~1...</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7397">现代史(1917年~...</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7402'">中国史
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7403">通史</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7422">原始社会(约60万年...</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7423">奴隶社会(约公元前2...</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7432">封建社会(公元前47...</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7508">半殖民地、半封建社会...</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7651">民族史志</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7656">地方史志</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7660'">亚洲史
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7661">通史</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7667">民族史志</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7668">东亚</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7720">东南亚</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=7879">西亚(西南亚)</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=8428'">欧洲史
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=8429">通史</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=8436">东欧、中欧</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=8868'">美洲史
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=8905">拉丁美洲</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9122'">传记
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9126">世界人物传记</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9135">中国人物传记</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9185'">文物考古
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9187">纹章学</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9188">考古方法</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9192">世界文物考古</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9193">中国文物考古</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9286'">风俗习惯
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9287">民俗学</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9288">世界风俗习惯</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9289">中国风俗习惯</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9309'">地理
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9310">地理学</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9325">世界地理</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9332">中国地理</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=9359">地图</a>
</dd>
</dl>
</div>
</div>
</li>
<li class="item mod_cate">
<h2><i class="arrow_dot fr"></i><a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=51127">综合性图书</a>
</h2>
<div class="item-list clearfix mod_subcate">
<div class="subitem mod_subcate_main">
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=51128'">丛书
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=51129">中国丛书</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=51151'">百科全书、类书
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=51152">中国百科全书、类书</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=51168'">辞典
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=51169">中国辞典</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=51170">各国辞典</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=51172'">论文集、全集、选集、...
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=51173">中国论文集、全集、选...</a>
</dd>
</dl>
<dl>
<dt style="cursor:pointer;" onclick="parent.location.href='/shop/book/Booksimple/list.do?showQueryModel.bookclcId=51184'">图书目录、文摘、索引
</dt>
<dd>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=51204">各类型目录</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=51227">专科目录</a>
<a target="_parent" href="/shop/book/Booksimple/list.do?showQueryModel.bookclcId=51228">文摘、索引</a>
</dd>
</dl>
</div>
</div>
</li>
</ul>
</div>
</li>
</ul>
</div>
<div class="scroll_nav_logo col-md-2 col-sm-4 col-xs-5">
<img class="scroll_nav_img" src="/kxwk5_style/images/nav_logo.png" />
</div>
<div class="col-md-10 col-sm-8 col-xs-7">
<nav class="navbar navbar-default">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- <a style="font-weight: bold;" class="navbar-brand" href="#">数理</a> -->
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav nav_link_container">
<li class="">
<a class="nav_link" data-name="75e48243889111e7a2df00163e2ed6f9" href="/shop/book/Booksimple/list.do?showQueryModel.dp1Value=75e48243889111e7a2df00163e2ed6f9">
数理
</a>
</li>
<li class="">
<a class="nav_link" data-name="57ed86a0889211e7a2df00163e2ed6f9" href="/shop/book/Booksimple/list.do?showQueryModel.dp1Value=57ed86a0889211e7a2df00163e2ed6f9">
化学材料
</a>
</li>
<li class="">
<a class="nav_link" data-name="6a4dcb6a889211e7a2df00163e2ed6f9" href="/shop/book/Booksimple/list.do?showQueryModel.dp1Value=6a4dcb6a889211e7a2df00163e2ed6f9">
生命
</a>
</li>
<li class="">
<a class="nav_link" data-name="7dee8d8a889211e7a2df00163e2ed6f9" href="/shop/book/Booksimple/list.do?showQueryModel.dp1Value=7dee8d8a889211e7a2df00163e2ed6f9">
地球
</a>
</li>
<li class="">
<a class="nav_link" data-name="8ab2fb16889211e7a2df00163e2ed6f9" href="/shop/book/Booksimple/list.do?showQueryModel.dp1Value=8ab2fb16889211e7a2df00163e2ed6f9">
资源环境
</a>
</li>
<li class="">
<a class="nav_link" data-name="99603fad889211e7a2df00163e2ed6f9" href="/shop/book/Booksimple/list.do?showQueryModel.dp1Value=99603fad889211e7a2df00163e2ed6f9">
农林
</a>
</li>
<li class="">
<a class="nav_link" data-name="a95a1a87889211e7a2df00163e2ed6f9" href="/shop/book/Booksimple/list.do?showQueryModel.dp1Value=a95a1a87889211e7a2df00163e2ed6f9">
医药
</a>
</li>
<li class="">
<a class="nav_link" data-name="c57f833d889211e7a2df00163e2ed6f9" href="/shop/book/Booksimple/list.do?showQueryModel.dp1Value=c57f833d889211e7a2df00163e2ed6f9">
信息
</a>
</li>
<li class="">
<a class="nav_link" data-name="d97783da889211e7a2df00163e2ed6f9" href="/shop/book/Booksimple/list.do?showQueryModel.dp1Value=d97783da889211e7a2df00163e2ed6f9">
工程
</a>
</li>
<li class="">
<a class="nav_link" data-name="e689625e889211e7a2df00163e2ed6f9" href="/shop/book/Booksimple/list.do?showQueryModel.dp1Value=e689625e889211e7a2df00163e2ed6f9">
管理
</a>
</li>
<li class="">
<a class="nav_link" data-name="f4fe63b3889211e7a2df00163e2ed6f9" href="/shop/book/Booksimple/list.do?showQueryModel.dp1Value=f4fe63b3889211e7a2df00163e2ed6f9">
历史考古
</a>
</li>
<li class="">
<a class="nav_link" data-name="04f8a72b889311e7a2df00163e2ed6f9" href="/shop/book/Booksimple/list.do?showQueryModel.dp1Value=04f8a72b889311e7a2df00163e2ed6f9">
经济
</a>
</li>
<li class="">
<a class="nav_link" data-name="1208204e889311e7a2df00163e2ed6f9" href="/shop/book/Booksimple/list.do?showQueryModel.dp1Value=1208204e889311e7a2df00163e2ed6f9">
教育传播
</a>
</li>
<li class="">
<a class="nav_link" data-name="219dfba2889311e7a2df00163e2ed6f9" href="/shop/book/Booksimple/list.do?showQueryModel.dp1Value=219dfba2889311e7a2df00163e2ed6f9">
法哲社会
</a>
</li>
<li class="">
<a class="nav_link" data-name="2dd606e6889311e7a2df00163e2ed6f9" href="/shop/book/Booksimple/list.do?showQueryModel.dp1Value=2dd606e6889311e7a2df00163e2ed6f9">
公共阅读
</a>
</li>
<!--<li id="zhuanti_flag" class="" style="display:none"><a class="nav_link" data-name="subjectNavLink" href="#">专题</a></li> -->
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 模态框 登录 -->
<div class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header" style="text-align: center;">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
</button>
<h3 class="modal-title" id="exampleModalLabel"><b>欢迎登录系统</b></h3>
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="form-group">
<div class="col-xs-12">
<input type="text" class="form-control" id="txtName" name="username" placeholder="邮箱">
</div>
</div>
<div class="form-group" style="margin-bottom: 4px">
<div class="col-xs-12">
<input type="password" class="form-control" id="txtPwd" name="password" placeholder="密码">
</div>
</div>
<div class="form-group login_ip_container">
<div class="col-xs-12">
<span>本机IP:82.157.123.54</span>
</div>
</div>
<div class="form-group">
<div class="col-xs-6">
<input type="text" class="form-control" id="checkcode" name="checkcode" placeholder="验证码">
</div>
<div class="col-xs-6">
<img src="/kaptcha.jpg" id="kaptchaImage"alt="验证码" title="点击换图片"onclick="changeImage();"/>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<button id="login_btn" type="button" class="btn">登录系统</button>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<div class="form-group">
<div class="col-xs-12 third_login_title">
<span>通过第三方账号登录</span>
</div>
</div>
<div class="form-group">
<div class="col-xs-4">
<div class="kejiyun_container">
<a href="/shop/main/Login/kjyTxzLogin.do" id="kjyTxz" target="_parent">
<img src="/kxwk5_style/images/kejiyun.png">
</a>
</div>
</div>
<div class="col-xs-4">
<!--<a href="https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=101253044&redirect_uri=http%3A%2F%2Fbook.sciencereading.cn%2Fpublic_auth.jspx&scope=all">-->
<a href="javascript:;" onclick="qqlogin()" >
<div class="qq_container" id="qq_container">
<i class="fa fa-qq"></i>
</div>
</a>
</div>
<div class="col-xs-4">
<a href="https://open.weixin.qq.com/connect/qrconnect?appid=wxbbe72137831b14a5&redirect_uri=http%3A%2F%2Fbook.sciencereading.cn%2Fshop%2Fmain%2FLogin%2FweixinLogin.do&response_type=code&scope=snsapi_login&state=STATE#wechat_redirect">
<!--<a href="javascript:;">-->
<div class=" weixin_container">
<i class="fa fa-weixin"></i>
</div>
</a>
</div>
</div>
</div>
</div>
<div class="login_bottom_container">
<div class="row">
<div class="register_now col-xs-7">
<a href="/shop/member/Member/create.do"><span>还没有账号?立即注册</span></a>
</div>
<div class="forget_password col-xs-5">
<a href="/shop/member/Member/openFindPwd.do"><span>忘记密码?</span></a>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
jQuery('.all-sort-list > .item').hover(function(){
var eq = jQuery('.all-sort-list > .item').index(this), //获取当前滑过是第几个元素
h = jQuery('.all-sort-list').offset().top, //获取当前下拉菜单距离窗口多少像素
s = jQuery(window).scrollTop(), //获取游览器滚动了多少高度
i = jQuery(this).offset().top, //当前元素滑过距离窗口多少像素
item = jQuery(this).children('.item-list').height(), //下拉菜单子类内容容器的高度
sort = jQuery('.all-sort-list').height(); //父类分类列表容器的高度
if ( item < sort ){ //如果子类的高度小于父类的高度
if ( eq == 0 ){
jQuery(this).children('.item-list').css('top', (i-h));
} else {
jQuery(this).children('.item-list').css('top', (i-h)+1);
}
} else {
if ( s > h ) { //判断子类的显示位置,如果滚动的高度大于所有分类列表容器的高度
if ( i-s > 0 ){ //则 继续判断当前滑过容器的位置 是否有一半超出窗口一半在窗口内显示的Bug,
jQuery(this).children('.item-list').css('top', (s-h)+2 );
} else {
jQuery(this).children('.item-list').css('top', (s-h)-(-(i-s))+2 );
}
} else {
jQuery(this).children('.item-list').css('top', 3 );
}
}
jQuery(this).addClass('hover');
jQuery(this).children('.item-list').css('display','block');
},function(){
jQuery(this).removeClass('hover');
jQuery(this).children('.item-list').css('display','none');
});
jQuery('.item > .item-list > .close').click(function(){
jQuery(this).parent().parent().removeClass('hover');
jQuery(this).parent().hide();
});
</script>
<style>
@-webkit-keyframes blink {
0% { opacity: 1; }
50% { opacity: 1; }
50.01% { opacity: 0; }
100% { opacity: 0; }
}
@-moz-keyframes blink {
0% { opacity: 1; }
50% { opacity: 1; }
50.01% { opacity: 0; }
100% { opacity: 0; }
}
@-ms-keyframes blink {
0% { opacity: 1; }
50% { opacity: 1; }
50.01% { opacity: 0; }
100% { opacity: 0; }
}
@-o-keyframes blink {
0% { opacity: 1; }
50% { opacity: 1; }
50.01% { opacity: 0; }
100% { opacity: 0; }
}
.online .fa-bell-o {
animation: blink .75s linear infinite;
-webkit-animation: blink .75s linear infinite;
-moz-animation: blink .75s linear infinite;
-ms-animation: blink .75s linear infinite;
-o-animation: blink .75s linear infinite;
}
</style>
'''
menuList1 = re.findall(r'<li class="item mod_cate">.*?<h2><i class="arrow_dot fr"></i><a target="_parent" href="/shop/book/Booksimple/list.do\?showQueryModel.bookclcId=(.*?)">(.*?)\[(.*?)\]</a>(.*?)</li>', resp, re.S)
for item1 in menuList1:
print(f'・{fixdesc(item1)}(共有图书{fixdesc(item1)}本):{fixdesc(item1)}')
menuList2 = re.findall(r'<dt style=".*?" onclick="parent.location.href=\'/shop/book/Booksimple/list.do\?showQueryModel.bookclcId=(.*?)\'">(.*?)\[(.*?)\].*?</dt>.*?<dd>(.*?)</dd>', item1, re.S)
for item2 in menuList2:
print(f' ・{fixdesc(item2)}(共有图书{fixdesc(item2)}本):{fixdesc(item2)}')
menuList3 = re.findall(r'<a target="_parent" href="/shop/book/Booksimple/list.do\?showQueryModel.bookclcId=(.*?)">(.*?)\[(.*?)\].*?</a>', item2, re.S)
for item3 in menuList3:
print(f' ・{fixdesc(item3)}(共有图书{fixdesc(item3)}本):{fixdesc(item3)}') 本程序的输出为
・文学(共有图书165本):6093
・文学理论(共有图书11本):6094
・文学创作论(共有图书5本):6107
・各体文学理论和创作方...(共有图书3本):6114
・文学评论、文学欣赏(共有图书1本):6125
・世界文学(共有图书14本):6126
・作品评论和研究(共有图书9本):6127
・作品集(共有图书5本):6145
・中国文学(共有图书97本):6156
・文学评论和研究(共有图书11本):6158
・各体文学评论和研究(共有图书23本):6164
・文学史、文学思想史(共有图书9本):6206
・作品集(共有图书6本):6208
・诗歌、韵文(共有图书3本):6228
・小说(共有图书5本):6310
・报告文学(共有图书14本):6328
・散文(共有图书18本):6340
・儿童文学(共有图书7本):6371
・艺术(共有图书308本):6397
・艺术理论(共有图书35本):6398
・艺术与其他科学的关系(共有图书3本):6401
・艺术美学(共有图书1本):6402
・造型艺术理论(共有图书31本):6416
・世界各国艺术概况(共有图书6本):6422
・中国艺术(共有图书5本):6432
・宗教艺术(共有图书1本):6440
・绘画(共有图书77本):6441
・绘画理论(共有图书9本):6444
・绘画技法(共有图书46本):6459
・中国绘画作品(共有图书4本):6500
・各国绘画作品(共有图书18本):6516
・书法、篆刻(共有图书17本):6529
・中国书法、篆刻(共有图书15本):6530
・外文书法(共有图书2本):6559
・雕塑(共有图书4本):6560
・雕塑技法(共有图书2本):6572
・中国雕塑作品(共有图书2本):6598
・摄影艺术(共有图书58本):6618
・摄影艺术理论(共有图书4本):6619
・各种摄影艺术(共有图书54本):6629
・工艺美术(共有图书42本):6649
・图案学(共有图书2本):6661
・中国工艺美术(共有图书33本):6662
・各国工艺美术(共有图书7本):6711
・音乐(共有图书31本):6713
・音乐理论(共有图书8本):6714
・音乐技术理论与方法(共有图书8本):6730
・器乐理论与演奏法(共有图书5本):6784
・民族器乐理论和演奏法(共有图书3本):6830
・中国音乐作品(共有图书4本):6867
・舞蹈(共有图书4本):7053
・舞蹈理论(共有图书1本):7054
・戏剧艺术(共有图书10本):7147
・戏剧艺术理论(共有图书1本):7148
・舞台艺术(共有图书1本):7164
・中国戏剧艺术(共有图书8本):7190
・电影、电视艺术(共有图书16本):7233
・电影、电视艺术理论(共有图书4本):7234
・电影、电视艺术与技术(共有图书2本):7246
・电影、电视拍摄艺术与...(共有图书2本):7264
・电影、电视企业组织与...(共有图书1本):7272
・各种电影、电视:按内...(共有图书4本):7286
・电影、电视事业(共有图书1本):7338
・历史、地理(共有图书2,024本):7354
・史学理论(共有图书6本):7355
・社会发展理论(共有图书3本):7357
・历史研究(共有图书1本):7361
・史学史(共有图书1本):7365
・世界史(共有图书8本):7369
・通史(共有图书4本):7370
・古代史(公元前40世...(共有图书1本):7381
・近代史(1640~1...(共有图书1本):7393
・现代史(1917年~...(共有图书2本):7397
・中国史(共有图书196本):7402
・通史(共有图书34本):7403
・原始社会(约60万年...(共有图书4本):7422
・奴隶社会(约公元前2...(共有图书13本):7423
・封建社会(公元前47...(共有图书31本):7432
・半殖民地、半封建社会...(共有图书9本):7508
・民族史志(共有图书29本):7651
・地方史志(共有图书76本):7656
・亚洲史(共有图书9本):7660
・通史(共有图书1本):7661
・民族史志(共有图书1本):7667
・东亚(共有图书3本):7668
・东南亚(共有图书1本):7720
・西亚(西南亚)(共有图书3本):7879
・欧洲史(共有图书3本):8428
・通史(共有图书1本):8429
・东欧、中欧(共有图书2本):8436
・美洲史(共有图书2本):8868
・拉丁美洲(共有图书2本):8905
・传记(共有图书281本):9122
・世界人物传记(共有图书3本):9126
・中国人物传记(共有图书244本):9135
・文物考古(共有图书1,166本):9185
・纹章学(共有图书1本):9187
・考古方法(共有图书9本):9188
・世界文物考古(共有图书3本):9192
・中国文物考古(共有图书1,134本):9193
・风俗习惯(共有图书28本):9286
・民俗学(共有图书1本):9287
・世界风俗习惯(共有图书9本):9288
・中国风俗习惯(共有图书17本):9289
・地理(共有图书255本):9309
・地理学(共有图书51本):9310
・世界地理(共有图书8本):9325
・中国地理(共有图书138本):9332
・地图(共有图书2本):9359
・综合性图书(共有图书94本):51127
・丛书(共有图书4本):51128
・中国丛书(共有图书4本):51129
・百科全书、类书(共有图书9本):51151
・中国百科全书、类书(共有图书9本):51152
・辞典(共有图书2本):51168
・中国辞典(共有图书1本):51169
・各国辞典(共有图书1本):51170
・论文集、全集、选集、...(共有图书19本):51172
・中国论文集、全集、选...(共有图书18本):51173
・图书目录、文摘、索引(共有图书28本):51184
・各类型目录(共有图书4本):51204
・专科目录(共有图书16本):51227
・文摘、索引(共有图书8本):51228 我还是更喜欢用xpah更简单好用一些。 这个我会 你看呀:
[!(https://s1.ax1x.com/2022/04/23/LhF0QU.jpg)](https://imgtu.com/i/LhF0QU)
```py
from bs4 import BeautifulSoup
with open('d:/html.html', 'r', encoding='utf-8') as f:
html = f.read()
node_li = BeautifulSoup(html, 'lxml')('li', class_='item mod_cate')
for li in node_li:
print('='*110, '\n', li.h2.a.string) # 第一分类
for dl in li.div.div('dl'):
cate =
print('{}\n {}:{}'.format('-'*110, cate, ' '.join(cate))) # 第二分类和第三分类
``` 应该可以,但xpath和re更容易一些,beautifulsoup没深入学
页:
[1]