当前位置: 首页>>代码示例>>Python>>正文


Python Tag.find方法代码示例

本文整理汇总了Python中bs4.Tag.find方法的典型用法代码示例。如果您正苦于以下问题:Python Tag.find方法的具体用法?Python Tag.find怎么用?Python Tag.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bs4.Tag的用法示例。


在下文中一共展示了Tag.find方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fetch_all_data

# 需要导入模块: from bs4 import Tag [as 别名]
# 或者: from bs4.Tag import find [as 别名]
def fetch_all_data(post: Tag):
    title = post.find(style='font-size: 18px').text
    post_datetime = grab_post_datetime(post)
    file_name = clean_filename(post_datetime + '-' + title)
    print('  Creating folder: ' + file_name)
    makedirs(file_name)
    chdir(file_name)
    download_images(post)
    text = post.find(style='font-size: 13px').text
    print('    Saving post text')
    with open('post_text.txt', 'w+', encoding='utf-8') as post_text_file:
        post_text_file.write(text)
    chdir('..')
    post_monolith.append((post_datetime, title + '\n' + text + '\n\n'))
开发者ID:wulfhaven,项目名称:FetchSporthojBlogg,代码行数:16,代码来源:download_blog.py

示例2: convert_to_dict

# 需要导入模块: from bs4 import Tag [as 别名]
# 或者: from bs4.Tag import find [as 别名]
        def convert_to_dict(rule_tag: Tag):
            nonlocal order
            ret_dict = {}
            atom = rule_tag.find("Atom")
            try:
                pattern = atom['value']

                ret_dict['order'] = order
                # some fixes for rule kinds
                # we've got: prefix, inside, suffix, exact
                if atom['kind'] == "prefix":
                    ret_dict['pattern'] = pattern + "\.\*"
                elif atom['kind'] == "inside":
                    ret_dict['pattern'] = "\.\*"+pattern+"\.\*"
                elif atom['kind'] == "suffix":
                    ret_dict['pattern'] = "\.\*"+pattern
                else:
                    ret_dict['pattern'] = pattern
                ret_dict['actions'] = []
                for action in rule_tag.children:
                    if action is not None:
                        try:
                            if action.name.lower() in actions:
                                ret_dict['actions'].append(action.name.lower())
                        except AttributeError:
                            pass
                order += 1
                return ret_dict
            except TypeError:
                return None
开发者ID:ifrpl,项目名称:toddler,代码行数:32,代码来源:nimbuscrawl.py

示例3: get_date

# 需要导入模块: from bs4 import Tag [as 别名]
# 或者: from bs4.Tag import find [as 别名]
def get_date(result: Tag) -> str:
    try:
        return result.find("p", {"class": "date_x"}).text.strip()
    except:
        return ""
开发者ID:honk3d,项目名称:ImdbTagSystem,代码行数:7,代码来源:ProcessMovieBlog.py

示例4: grab_post_datetime

# 需要导入模块: from bs4 import Tag [as 别名]
# 或者: from bs4.Tag import find [as 别名]
def grab_post_datetime(post: Tag) -> string:
    time_text = post.find(id='publicerad').text
    date_time_string = re.search(r'Tidpunkt:(.+)[|]', time_text).group(1).strip()
    post_datetime = datetime.datetime.strptime(date_time_string, '%d / %m - %Y %H:%M').strftime('%y-%m-%d_%H:%M')
    return post_datetime
开发者ID:wulfhaven,项目名称:FetchSporthojBlogg,代码行数:7,代码来源:download_blog.py


注:本文中的bs4.Tag.find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。