本文整理汇总了Python中dominate.document方法的典型用法代码示例。如果您正苦于以下问题:Python dominate.document方法的具体用法?Python dominate.document怎么用?Python dominate.document使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dominate
的用法示例。
在下文中一共展示了dominate.document方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import dominate [as 别名]
# 或者: from dominate import document [as 别名]
def __init__(self, web_dir, title, refresh=0):
"""Initialize the HTML classes
Parameters:
web_dir (str) -- a directory that stores the webpage. HTML file will be created at <web_dir>/index.html; images will be saved at <web_dir/images/
title (str) -- the webpage name
refresh (int) -- how often the website refresh itself; if 0; no refreshing
"""
self.title = title
self.web_dir = web_dir
self.img_dir = os.path.join(self.web_dir, 'images')
if not os.path.exists(self.web_dir):
os.makedirs(self.web_dir)
if not os.path.exists(self.img_dir):
os.makedirs(self.img_dir)
self.doc = dominate.document(title=title)
if refresh > 0:
with self.doc.head:
meta(http_equiv="refresh", content=str(refresh))
示例2: __init__
# 需要导入模块: import dominate [as 别名]
# 或者: from dominate import document [as 别名]
def __init__(self, web_dir, title, image_subdir='', reflesh=0):
self.title = title
self.web_dir = web_dir
# self.img_dir = os.path.join(self.web_dir, )
self.img_subdir = image_subdir
self.img_dir = os.path.join(self.web_dir, image_subdir)
if not os.path.exists(self.web_dir):
os.makedirs(self.web_dir)
if not os.path.exists(self.img_dir):
os.makedirs(self.img_dir)
# print(self.img_dir)
self.doc = dominate.document(title=title)
if reflesh > 0:
with self.doc.head:
meta(http_equiv="reflesh", content=str(reflesh))
示例3: generate_html
# 需要导入模块: import dominate [as 别名]
# 或者: from dominate import document [as 别名]
def generate_html(paragraphs, title_text):
doc = dominate.document(title='Summary: {}'.format(title_text))
with doc.head:
style("""\
body {
background-color: #F9F8F1;
color: #2C232A;
font-family: sans-serif;
font-size: 1.2em;
}
""")
with doc:
div(id='header').add(h1(title_text))
with div():
attr(cls='body')
for para in paragraphs:
tb = TextBlob(para)
with p():
for sentence in tb.sentences:
span(sentence, style="color: {}".format(get_polarity_color(sentence.polarity)))
return doc
示例4: generate_html
# 需要导入模块: import dominate [as 别名]
# 或者: from dominate import document [as 别名]
def generate_html(sentences, title_text):
doc = dominate.document(title='Summary: {}'.format(title_text))
with doc.head:
style("""\
body {
background-color: #F9F8F1;
color: #2C232A;
font-family: sans-serif;
font-size: 2.6em;
margin: 3em 1em;
}
""")
with doc:
div(id='header').add(h1(title_text))
with div():
attr(cls='body')
for sentence in sentences:
p(sentence)
return doc
示例5: summarize_text
# 需要导入模块: import dominate [as 别名]
# 或者: from dominate import document [as 别名]
def summarize_text(request):
if request.html:
parser = HtmlParser.from_file(file_path=request.html,
url=request.url,
tokenizer=Tokenizer(LANGUAGE))
else:
parser = PlaintextParser.from_file(file_path=request.html,
tokenizer=Tokenizer(LANGUAGE))
stemmer = Stemmer(LANGUAGE)
summarizer = Summarizer(stemmer)
summarizer.stop_words = get_stop_words(LANGUAGE)
sentences = [fix_text(str(s)) for s in summarizer(parser.document, SENTENCES_COUNT)]
html = generate_html(sentences, fix_text(request.title)).render()
request.send_html(html)
示例6: __init__
# 需要导入模块: import dominate [as 别名]
# 或者: from dominate import document [as 别名]
def __init__(self, web_dir, title, reflesh=0):
self.title = title
self.web_dir = web_dir
self.img_dir = os.path.join(self.web_dir, 'images')
if not os.path.exists(self.web_dir):
os.makedirs(self.web_dir)
if not os.path.exists(self.img_dir):
os.makedirs(self.img_dir)
# print(self.img_dir)
self.doc = dominate.document(title=title)
if reflesh > 0:
with self.doc.head:
meta(http_equiv="reflesh", content=str(reflesh))
示例7: __init__
# 需要导入模块: import dominate [as 别名]
# 或者: from dominate import document [as 别名]
def __init__(self, web_fold, t):
self.title = t
self.web_fold = web_fold
self.img_fold = os.path.join(self.web_fold, 'images')
if not os.path.exists(self.web_fold):
os.makedirs(self.web_fold)
if not os.path.exists(self.img_fold):
os.makedirs(self.img_fold)
print(self.img_fold)
self.doc = dominate.document(title=t)
示例8: __init__
# 需要导入模块: import dominate [as 别名]
# 或者: from dominate import document [as 别名]
def __init__(self, web_dir, title, refresh=0):
self.title = title
self.web_dir = web_dir
self.img_dir = os.path.join(self.web_dir, 'images')
if not os.path.exists(self.web_dir):
os.makedirs(self.web_dir)
if not os.path.exists(self.img_dir):
os.makedirs(self.img_dir)
self.doc = dominate.document(title=title)
if refresh > 0:
with self.doc.head:
meta(http_equiv="refresh", content=str(refresh))
示例9: __init__
# 需要导入模块: import dominate [as 别名]
# 或者: from dominate import document [as 别名]
def __init__(self, html_file='./index.html', refresh=0):
self.html_file = html_file
self.doc = dominate.document(title='simple_html')
if refresh > 0:
with self.doc.head:
meta(http_equiv="reflesh", content=str(refresh))
示例10: __init__
# 需要导入模块: import dominate [as 别名]
# 或者: from dominate import document [as 别名]
def __init__(self, web_dir, title, reflesh=0):
self.title = title
self.web_dir = web_dir
self.img_dir = os.path.join(self.web_dir, 'images')
if not os.path.exists(self.web_dir):
os.makedirs(self.web_dir)
if not os.path.exists(self.img_dir):
os.makedirs(self.img_dir)
# print(self.img_dir)
self.doc = dominate.document(title=title)
if reflesh > 0:
with self.doc.head:
meta(http_equiv="reflesh", content=str(reflesh))
self.t = None