import requests
from bs4 import BeautifulSoup


def scrape_canto(url):
    """
    Scrapes the body of each Canto. Source: Wikisource
    """
    ## Get html data
    page = requests.get(url)
    soup = BeautifulSoup(page.content, 'html.parser')

    ## Get Canto
    body = soup.find_all('div', class_='poem')
    body = [ verse.get_text() for verse in body ]

    body = "\n".join(body)
    body = body.replace("\xa0", u" ")
    body = body.replace("«", u"\"")
    body = body.replace("»", u"\"")
    body = body.replace("’", u"'")
    body = body.replace(" .mw-parser-output .numeroriga{float:right;color:#666;font-size:70%}3", u"")
    body = body.strip()

    return body