Skip to content

Instantly share code, notes, and snippets.

@hellojinjie
Created November 3, 2019 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellojinjie/146babc45842165f1d29dda0cf517f08 to your computer and use it in GitHub Desktop.
Save hellojinjie/146babc45842165f1d29dda0cf517f08 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import requests
from bs4 import BeautifulSoup
import sqlite3
from pathvalidate import sanitize_filepath, sanitize_filename
import os
def start():
num = 151
while num < 400:
dir = f"D:/Drawer/Jenny/Jenny_{num}"
if not os.path.exists(dir): os.mkdir(dir)
url = f"https://www.lrts.me/ajax/playlist/1/37987/{num}/next"
print(url)
response = requests.get(url, headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36'})
bs = BeautifulSoup(response.content, 'html.parser')
items = bs.select('.section-item')
for item in items:
number = item.select_one('.section-number')
print(number.text)
source = item.select_one('input[name="source"]')
print(source['value'])
name = item.select_one('input[name="player-r-name"]')
print(name['value'])
filePath = f"D:/Drawer/Jenny/Jenny_{num}/{number.text}_{sanitize_filename(name['value'])}.mp3"
with open(filePath, 'wb') as f:
f.write(requests.get(source['value']).content)
num = num + 10
if __name__ == "__main__":
start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment