陷入困境

时间:2016-02-16 19:34:46

标签: python python-3.x web-scraping beautifulsoup

我想刮掉自动化的boringstuff.com并输出所有练习项目并将它们存储到一个文件中。最终我希望我的代码从一个页面移动到下一个搜索练习项目,但是现在我只是试图让beautifulsoup在一个页面上输出练习项目。虽然不行。我只是得到一个空白的[]。

到目前为止,这是我的代码。

def pageDownload(webPage):
    # Downloads the page

    while not url.endswith('appendixc'):
        print('Downloading page %s...' % url)
        res = requests.get(url)
        res.raise_for_status()

        soup = bs4.BeautifulSoup(res.text)

        return soup

def getProjects(downloadedPage):
    # gets the projects contents

    soup = downloadedPage
    book =  soup.find_all('p', attrs={'title' : 'Practice Projects'})
    print(book)

1 个答案:

答案 0 :(得分:1)

试试这个。

Service 'SparkUI' could not bind on port 4040. Attempting port 4041.
相关问题