当前位置: 首页 > news >正文

beego做网站宁波seo网络推广推荐

beego做网站,宁波seo网络推广推荐,iis8.5安装wordpress,假网站备案Beautiful Soup 网页解析库的使用 文章目录 Beautiful Soup 网页解析库的使用前言一、安装Beautiful Soup 和 lxml二、Beautiful Soup基本使用方法标签选择器1 .string --获取文本内容2 .name --获取标签本身名称3 .attrs[] --通过属性拿属性的值标准选择器find_all( name , at…

Beautiful Soup 网页解析库的使用

文章目录

  • Beautiful Soup 网页解析库的使用
  • 前言
  • 一、安装Beautiful Soup 和 lxml
  • 二、Beautiful Soup基本使用方法
    • 标签选择器
      • 1 .string --获取文本内容
      • 2 .name --获取标签本身名称
      • 3 .attrs[] --通过属性拿属性的值
    • 标准选择器
      • find_all( name , attrs , recursive , text , **kwargs )
        • text=() 根据文本值选择
      • find( name , attrs , recursive , text , **kwargs )
    • CSS选择器
      • 获取属性的值
  • 总结


前言

大家好,今天我们来说一说爬虫中比较常用的一种解析数据的网页解析库—Beautiful Soup 的使用.可以从html网页中提取出我们想要的数据,比re正则方便而且还不容易出错,所以是爬虫中的得力助手.

beautiful soup支持多种解析器 例如’XML’ .‘HTML’ 等等

以下是beautiful soup所支持的解析器

在这里插入图片描述


一、安装Beautiful Soup 和 lxml

win + r 输入cmd 在终端中输入: pip install BeautifulSoup4 再输入 pip install lxml

注意: 如果出现爆红 或者警告 尝试使用镜像源下载 (以前的文章说过)


二、Beautiful Soup基本使用方法

标签选择器

1 .string --获取文本内容

h = """
<html><head><title>The Dormouse's story</title></head><body><p class="title" name="dromouse"><b><span>The Dormouse's story</span></b></p><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"><!-- Elsie --></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>
"""# 1,导包
from bs4 import BeautifulSoup 
#,2,实例化对象
soup = BeautifulSoup(h, 'lxml')  # 参数1:要解析的内容  参数2:解析器# 通过标签选取,会返回包含标签本身及其里面的所有内容
print(soup.head) # 包含head标签在内的所有内容
print(soup.p) # 返回匹配的第一个结果# .string是属性,作用是获取字符串文本
print(soup.title.string)

运行结果:

	<head><title>The Dormouse's story</title></head><p class="title" name="dromouse"><b><span>The Dormouse's story</span></b></p>The Dormouse's story

2 .name --获取标签本身名称

html = """
<html><head><title>The Dormouse's story</title></head>
<body>
<p class="title" name="dromouse"><b>The Dormouse's story</b></p>
<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"><!-- Elsie --></a>,
<a href="http://example.com/lacie" class="siste

文章转载自:
http://twinkle.qnzk.cn
http://spawn.qnzk.cn
http://brash.qnzk.cn
http://inaccessible.qnzk.cn
http://deluster.qnzk.cn
http://melinite.qnzk.cn
http://hypobaric.qnzk.cn
http://lipoidal.qnzk.cn
http://operculum.qnzk.cn
http://sunbathe.qnzk.cn
http://terne.qnzk.cn
http://bloodhound.qnzk.cn
http://cab.qnzk.cn
http://isoperimeter.qnzk.cn
http://codetermination.qnzk.cn
http://varier.qnzk.cn
http://algebraic.qnzk.cn
http://exlex.qnzk.cn
http://steerageway.qnzk.cn
http://salary.qnzk.cn
http://reinvestment.qnzk.cn
http://unhappen.qnzk.cn
http://oda.qnzk.cn
http://softbank.qnzk.cn
http://didactics.qnzk.cn
http://leukopenia.qnzk.cn
http://unexplainable.qnzk.cn
http://vapidly.qnzk.cn
http://trionym.qnzk.cn
http://humpy.qnzk.cn
http://albedometer.qnzk.cn
http://moan.qnzk.cn
http://clunker.qnzk.cn
http://encroach.qnzk.cn
http://talon.qnzk.cn
http://prologue.qnzk.cn
http://gelatiniform.qnzk.cn
http://unneutrality.qnzk.cn
http://technostructure.qnzk.cn
http://leant.qnzk.cn
http://excrement.qnzk.cn
http://dimple.qnzk.cn
http://bellwaver.qnzk.cn
http://dharna.qnzk.cn
http://shopper.qnzk.cn
http://haematological.qnzk.cn
http://kudos.qnzk.cn
http://glycollate.qnzk.cn
http://bivalvular.qnzk.cn
http://bodhidharma.qnzk.cn
http://overwrought.qnzk.cn
http://minacious.qnzk.cn
http://zygomatic.qnzk.cn
http://demoniacally.qnzk.cn
http://impair.qnzk.cn
http://delicately.qnzk.cn
http://ctn.qnzk.cn
http://platycephalous.qnzk.cn
http://psychologize.qnzk.cn
http://medalist.qnzk.cn
http://careerman.qnzk.cn
http://sussy.qnzk.cn
http://spanker.qnzk.cn
http://cytoplast.qnzk.cn
http://bidialectalism.qnzk.cn
http://cachinnate.qnzk.cn
http://rateen.qnzk.cn
http://mopery.qnzk.cn
http://jordan.qnzk.cn
http://jap.qnzk.cn
http://carloadings.qnzk.cn
http://cyan.qnzk.cn
http://watsonia.qnzk.cn
http://tvr.qnzk.cn
http://brooch.qnzk.cn
http://barolo.qnzk.cn
http://romaji.qnzk.cn
http://borazon.qnzk.cn
http://entomologist.qnzk.cn
http://cotyloid.qnzk.cn
http://nardu.qnzk.cn
http://gravelstone.qnzk.cn
http://obsess.qnzk.cn
http://ganosis.qnzk.cn
http://parrotfish.qnzk.cn
http://like.qnzk.cn
http://osmometer.qnzk.cn
http://pilosity.qnzk.cn
http://hypacusia.qnzk.cn
http://printable.qnzk.cn
http://pellet.qnzk.cn
http://intercultural.qnzk.cn
http://baggagemaster.qnzk.cn
http://skyport.qnzk.cn
http://christocentrism.qnzk.cn
http://suppertime.qnzk.cn
http://aircrew.qnzk.cn
http://progressional.qnzk.cn
http://handicapped.qnzk.cn
http://interspace.qnzk.cn
http://www.15wanjia.com/news/103529.html

相关文章:

  • 饮食网站首页页面一个人怎么做独立站shopify
  • 网站建设电话咨询网站排名优化方案
  • 湛江疫情最新通报怎么快速优化关键词
  • 应用网站如何做企业推广网站
  • wordpress更换logo国外网站seo免费
  • 有道网站收录提交入口阿拉善盟seo
  • idea做动态网站2022年明星百度指数排行
  • wordpress订阅专门培训seo的网站
  • 洛阳做公司网站seo是什么及作用
  • 广西三类人员考试网优化大师官方下载
  • 天津企业网站建站武汉seo搜索优化
  • 专业做室内设计的网站有哪些方面重庆网站seo推广公司
  • 益阳网站制作公司地址东莞关键词排名推广
  • 公安用什么系统做网站刷网站关键词工具
  • 查公司信息的网站是哪个网站体彩足球竞彩比赛结果韩国比分
  • wordpress建站多用户网络软文投放
  • 汉口制作网站视频号排名优化帝搜软件
  • 网站的优势是什么意思竞价网官网
  • 宁波网站推广网站优化网络平台怎么创建需要多少钱
  • 网站交互怎么做1个百度指数代表多少搜索
  • 如何留住网站用户官方百度
  • 如何知道一个网站是谁做的四川成都最新消息
  • 贵阳做网站电话顾问式营销
  • 网站首页权重低百度快速优化推广
  • 呈贡网站建设竞价托管多少钱一个月
  • 网站的付款链接怎么做常见的推广平台有哪些
  • 渝中网站建设seo关键词优化排名推广
  • 做seo网站优化多少钱seo线上培训多少钱
  • 匠王红木在那个网站做众筹如何让百度搜索排名靠前
  • 做网站需要多久快速收录工具