本文整理汇总了Python中book.Book.to_tsv方法的典型用法代码示例。如果您正苦于以下问题:Python Book.to_tsv方法的具体用法?Python Book.to_tsv怎么用?Python Book.to_tsv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类book.Book
的用法示例。
在下文中一共展示了Book.to_tsv方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: from book import Book [as 别名]
# 或者: from book.Book import to_tsv [as 别名]
series_page_html = r.read()
with open(series_page_file, 'w') as f:
f.write(series_page_html)
time.sleep(1)
# get links for every book in the series
book_links = parse_book_links(series.href, series_page_html)
logging.info('Found %d books' % len(book_links))
for book_link in book_links:
# get and download the book html_line_to_series
if book_link.title is None:
continue
logging.info('Examining book %s from %s' % (book_link.title, book_link.href))
book_file = 'data/html/%s_%s.html' % (clean_name(series.name), clean_name(book_link.title))
if os.path.exists(book_file):
logging.info('Reading book data from cached html file')
with open(book_file) as f:
book_html = f.read()
else:
logging.info('Reading book data from the web')
r = br.open(book_link.href)
book_html = r.read()
with open(book_file, 'w') as f:
f.write(book_html)
time.sleep(1)
book = Book(series.name, book_link.title, book_link.href, book_html)
with open(output_file, 'a') as f:
f.write(book.to_tsv())
f.write("\n")