示例#1
0
def get_mark(bookId):
    res = ''
    is_print_all = input('选择:所有标注/指定章节的标注(1/2)?\n')
    if is_print_all.strip() == '1':  # 如果选择输出所有标注
        way_to_print_chapter = input('选择:包含所有标题/只包含有标注的标题(1/2)?\n')
        if way_to_print_chapter.strip() == '1':  # 如果选择输出所有标题
            res = get_bookmarklist(bookId)
        elif way_to_print_chapter.strip() == '2':  # 如果选择只输出包含标注的标题
            res = get_bookmarklist(bookId, is_all_chapter=0)
        else:
            print('其他指令,默认包含所有标题\n')
            res = get_bookmarklist(bookId)
    elif is_print_all.strip() == '2':  # 如果选择输出指定章节的标注
        # 输出章节id和章节名
        print_chapterUid_and_title(bookId)
        # 接收章节id并去除空符
        chapterUid_str = input('输入章节ID,多个ID用英文逗号分隔:\n').replace(' ', '')
        print('获取中...')
        # 遍历所有章节id
        for chapterUid_s in chapterUid_str.split(','):
            chapterUid = int(chapterUid_s)
            res += get_bookmarklist(bookId,
                                    is_all_chapter=1,
                                    chapterUid=chapterUid)
            print(chapterUid)
        print('获取结束')
    else:
        print('其他指令,默认返回所有标注\n')
        res = get_bookmarklist(bookId)
    # 没有标注时给出提示
    if res.strip() == '':
        print('无标注')
    return res
示例#2
0
def main():
    print('欢迎使用微信读书爬虫')
    try:
        books = get_bookshelf()
    except:
        print('请检查您的Cookie设置')
        return
    print('您的书架如下:')
    for b in books:
        print(b.bookId,b.title,b.author)

    while True:
        bid = input('想看哪本书的目录,请输入对应书籍id:')

        for c in get_chapters(int(bid)):
            print('#'*c[0],c[1])

        y =  input('是否需要查看该书的热门划线,y/n?')
        if y.lower() == 'y':
            bb = get_bestbookmarks(bid)
            print(bb)

        y =  input('是否需要查看你的笔记,y/n?')
        if y.lower() == 'y':
            bb = get_bookmarklist(bid)
            print(bb)

        y = input('是否需要查看其他书,y/n?')

        if y.lower() == 'y':
            continue
        else:
            print('bye~')
            break
示例#3
0
 def get_note(self, id):
     note_name = os.path.join(self.note_dir, "%s.md" % id)
     if os.path.exists(note_name):
         with open(note_name, "r", encoding="utf-8") as f:
             return f.read()
     else:
         return wereader.get_bookmarklist(id, cookies=self.cookies)
示例#4
0
def export_mine():
    global CURRENT

    bid = CURRENT.bookId
    bb = get_bookmarklist(bid, cookies=cookies)
    with open(f"{CURRENT.title}-{CURRENT.bookId}.{FMT}", "w") as f:
        f.write(bb)
    print("导出成功")
示例#5
0
def export_mine():
    global CURRENT

    bid = CURRENT.bookId
    bb = get_bookmarklist(bid)
    with open(f'{CURRENT.title}-{CURRENT.bookId}.{FMT}', 'w') as f:
        f.write(bb)
    print("导出成功")
示例#6
0
def old_main():
    print('欢迎使用微信读书爬虫')
    try:
        books = get_bookshelf()
    except:
        print('请检查您的Cookie设置')
        return
    print('您的书架如下:')
    for b in books:
        print(b.bookId, b.title, b.author)

    while True:
        bid = input('想看哪本书的目录,请输入对应书籍id:')
        current_book = [x for x in books if x.bookId == bid][0]

        for c in get_chapters(int(bid)):
            print('#' * c[0], c[1])

        y = input('是否需要查看该书的热门划线,y/n?')
        if y.lower() == 'y':
            bb = get_bestbookmarks(bid)
            print(bb)

        y = input('是否需要查看你的笔记,y/n?')
        if y.lower() == 'y':
            bb = get_bookmarklist(bid)
            print(bb)

        y = input('是否需要保存你的笔记,y/n?')
        if y.lower() == 'y':
            bb = get_bookmarklist(bid)
            with open(f'{current_book.title}-{current_book.bookId}.txt',
                      'w') as f:
                f.write(bb)

        y = input('是否需要查看其他书,y/n?')

        if y.lower() == 'y':
            continue
        else:
            print('bye~')
            break
示例#7
0
def see_mine():
    global CURRENT

    bid = CURRENT.bookId
    bb = get_bookmarklist(bid, cookies=cookies)
    print(bb)