Advertisement

Python爬虫用于获取小说内容

阅读量:
复制代码
    #加载模块
    import requests
    from bs4 import BeautifulSoup
    
    # 定义所有章节和链接函数
    def get_novel_chapters():
    url = "https://www.89wxw.com/read/1037/"
    r = requests.get(url)
    main_page = BeautifulSoup(r.text, "html.parser")
    list1 = []
    for dd in (main_page.find_all("dd")):
        link = dd.find("a")
        if not link:
            continue
        list1.append(("https://www.89wxw.com" + (link["href"]), (link.get_text())))
    return list1
    
    # 定义获取所有章节内容
    def get_chapters_content(url):
    r = requests.get(url)
    main_page = BeautifulSoup(r.text, "html.

全部评论 (0)

还没有任何评论哟~