本文实例讲述了python3 BeautifulSoup模块使用字典的方法抓取a标签内的数据。分享给大家供大家参考,具体如下:
# -*- coding:utf-8 -*-
#python 2.7
#XiaoDeng
#http://tieba.baidu.com/p/2460150866
#标签操作
from bs4 import BeautifulSoup
import urllib.request
import re
#如果是网址,可以用这个办法来读取网页
#html_doc = "http://tieba.baidu.com/p/2460150866"
#req = urllib.request.Request(html_doc)
#webpage = urllib.request.urlopen(req)
#html = webpage.read()
html="""
The Dormouse's storyThe Dormouse's story
Once upon a time there were three little sisters; and their names were
Lacie and

本文通过实例代码介绍了Python3使用BeautifulSoup模块抓取a标签内数据的方法,包括获取class、id、href属性及字符串内容,适用于网页爬虫开发。
最低0.47元/天 解锁文章


被折叠的 条评论
为什么被折叠?



