本文整理匯總了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