本文整理汇总了Python中pyquery.PyQuery.append方法的典型用法代码示例。如果您正苦于以下问题:Python PyQuery.append方法的具体用法?Python PyQuery.append怎么用?Python PyQuery.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyquery.PyQuery
的用法示例。
在下文中一共展示了PyQuery.append方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_text
# 需要导入模块: from pyquery import PyQuery [as 别名]
# 或者: from pyquery.PyQuery import append [as 别名]
def update_text(self, target, value):
elements = self.html_obj('*').filter('[dzid="' + target + '"]')
for e in elements:
pq = PyQuery(e)
pq.empty()
pq.append(value)
return True
return False
示例2: prepare_html
# 需要导入模块: from pyquery import PyQuery [as 别名]
# 或者: from pyquery.PyQuery import append [as 别名]
def prepare_html(fileobj):
""" prepares the html for wordpress pages """
pq=PyQuery("".join(strip_if_not_pre(fileobj)))
pq("a.headerlink").remove()
# Do we want title at all?
if pq("div.section h1"):
title= pq("div.section h1")[0].text
pq("div.section h1:first").remove()
else:
title=""
# TODO: insert toc (??)
out = PyQuery(pq("div.content").outerHtml() )
# insert after h1 on 4th ine
# lines = out.split('\n')
# out = '\n'.join(lines[:4] + [ '[toc]' ] + lines[4:])
# now various regex
out.append("<p><small>Last update: %s</small></p>"%(
datetime.datetime.now().strftime("%Y-%m-%d")))
out=out.outerHtml()
# replace .html with / and index.html with simple ./
pattern = '(internal" href=".[^"]*)index\.html"'
out = re.sub(pattern, '\\1"', out)
pattern = 'internal" href="index\.html"'
out = re.sub(pattern, 'href="./"', out)
pattern = '(internal" href="[^"]*).html"'
out = re.sub(pattern, '\\1/"', out)
pattern = '(internal" href="[^"]*).html#([^"]*)"'
out = re.sub(pattern, '\\1/#\\2"', out)
pattern = '(internal" href="[^"]*/)index/#([^"]*)"'
out = re.sub(pattern, '\\1/#\\2"', out)
return (out, title)