Created
January 6, 2020 18:22
-
-
Save honno/3f06cb3a6582f18f3623ef95406af0e1 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/python3 | |
import argparse | |
import sys | |
import requests | |
from bs4 import BeautifulSoup | |
def music_grid_parse(music_item): | |
return music_item.find('a')['href'] | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser() | |
parser.add_argument('url') | |
args = parser.parse_args(sys.argv[1:]) | |
page = requests.get(args.url) | |
page_soup = BeautifulSoup(page.text, 'html.parser') | |
music_list = page_soup.find_all('li', attrs={'class': 'music-grid-item'}) | |
album_slugs = map(music_grid_parse, music_list) | |
links = [args.url + slug for slug in album_slugs] | |
print(*links, sep="\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment