python 3利用BeautifulSoup抓取div标签的方法示例
前言
本文主要介绍的是关于python3用BeautifulSoup抓取div标签的方法示例,分享出来供大家参考学习,下面来看看详细的介绍:
示例代码:
#-*-coding:utf-8-*- #python2.7 #XiaoDeng #http://tieba.baidu.com/p/2460150866 #标签操作 frombs4importBeautifulSoup importurllib.request importre #如果是网址,可以用这个办法来读取网页 #html_doc="http://tieba.baidu.com/p/2460150866" #req=urllib.request.Request(html_doc) #webpage=urllib.request.urlopen(req) #html=webpage.read() html="""TheDormouse'sstory TheDormouse'sstory Onceuponatimetherewerethreelittlesisters;andtheirnameswere , Lacieand Tillie; Lacie andtheylivedatthebottomofawell. 加载中…