This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# importing packages | |
import requests | |
from bs4 import BeautifulSoup | |
import pandas as pd | |
def parse_website(url): | |
""" | |
Parse content of a website | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def filter_hyperlinks(urls): | |
""" Filter our hyperlinks that are not from lyrics taking into account the structure | |
of songteksten.nl website """ | |
list_links_lyrics_songteksten_net = [] | |
for url in urls: | |
list_links_lyrics_songteksten_net.extend(retrieve_hyperlinks(url)) | |
# removing possible duplicates |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
def retrieve_hyperlinks(main_url): | |
""" Extract all hyperlinks in 'main_url' and return a list with these hyperlinks """ | |
# Packages the request, send the request and catch the response: r | |
r = requests.get(main_url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
def retrieve_hyperlinks(main_url): | |
""" Extract all hyperlinks in 'main_url' and return a list with these hyperlinks """ | |
# Packages the request, send the request and catch the response: r | |
r = requests.get(main_url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Uploading the Dataset | |
from google.colab import files | |
uploaded = files.upload() | |
#Save uploaded file on the Virtual Machine's | |
#Thanks to user3800642 from StackOverflow | |
with open("breast_cancer.csv", 'w') as f: | |
f.write(uploaded[uploaded.keys()[0]]) |