本文整理汇总了Python中bs4.Tag.attrs['src']方法的典型用法代码示例。如果您正苦于以下问题:Python Tag.attrs['src']方法的具体用法?Python Tag.attrs['src']怎么用?Python Tag.attrs['src']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bs4.Tag
的用法示例。
在下文中一共展示了Tag.attrs['src']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clean_convert_links
# 需要导入模块: from bs4 import Tag [as 别名]
# 或者: from bs4.Tag import attrs['src'] [as 别名]
def clean_convert_links(in_page):
'''Adjust internal links so that the point to memory instead
of the ePub file. We start with images.'''
orig_link = None
pSoup = in_page
for image in pSoup.findAll('img'):
new_link = image.attrs['src'].strip('../')
image.attrs['src'] = 'memory:%s' % new_link
for image in pSoup.findAll('image'):
try:
image_link = image.attrs['xlink:href']
src_tag = Tag(pSoup, name='img')
src_tag.attrs['src'] = 'memory:%s'%image_link
image.replaceWith(src_tag)
except:
raise
# Conversions for other types of links will be added at a later time.
# This is to help ensure we don't convert the wrong links.
return pSoup.prettify('latin-1')