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


Python Book.to_tsv方法代码示例

本文整理汇总了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")
开发者ID:lotze,项目名称:romance_names,代码行数:32,代码来源:download_data.py


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