Skip to content

Instantly share code, notes, and snippets.

@liuyu81
Created November 23, 2015 13:40
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 liuyu81/869b77f4b72333424634 to your computer and use it in GitHub Desktop.
Save liuyu81/869b77f4b72333424634 to your computer and use it in GitHub Desktop.
QQ Music Downloader
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import requests
import sys
import time
from lxml import etree
def main(args):
PREFIX = "music"
tree = etree.parse(sys.stdin, etree.HTMLParser())
for i, music in enumerate(tree.xpath("//qqmusic"), 1):
name = music.get("music_name")
singer, sep, album = music.get("singer").partition(" - ")
uri = music.get("audiourl")
print(i, name, singer, uri)
response = requests.get(uri)
filename = "{0}({1}).m4a".format(name, singer)
with open(os.path.join(PREFIX, filename), "wb") as f:
f.write(response.content)
f.flush()
time.sleep(0.5)
return os.EX_OK
if __name__ == '__main__':
sys.exit(main(sys.argv[:]))
@giorgi-create
Copy link

giorgi-create commented Apr 27, 2020

how to install and how to use this can you write me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment