Skip to content

Instantly share code, notes, and snippets.

function gettingData(){
var txt;
var httpGetter = new XMLHttpRequest();
httpGetter.open("GET","file:///Users/jackbonadies/lastFMtop50/listOfFiles.txt",false);
httpGetter.onreadystatechange = function() {
if(httpGetter.readyState === 4){
if(httpGetter.status === 200 | httpGetter.status === 0){
var rawText = httpGetter.responseText;
txt = rawText;
return txt;
@jackBonadies
jackBonadies / lastFMalbums.py
Created April 13, 2019 21:02
Beautiful Soup is a great library to parse and scrap text or images from sites based on html tags. In this case I simply got all image tags. Also, subprocess can spawn shell processes such as rm and mkdir to get rid of the previous set of images. We use wget to download images from source and ls with piping to get text file.
#!/usr/bin/env python3
from bs4 import BeautifulSoup
import requests
import os
import subprocess
source=requests.get('https://www.last.fm/user/lastpriest/library/albums').text
soup=BeautifulSoup(source,'lxml')
albums=soup.find_all('img')
imgUrls = []
for album in albums: