1 Star 1 Fork 0

且听风吟/python

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
1.py 2.02 KB
一键复制 编辑 原始数据 按行查看 历史
且听风吟 提交于 2015-12-23 21:51 +08:00 . 添加项目文件
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'liangliang'
from ebooklib import epub
from MyZhiHu import *
from SetLrc import *
import urllib2
import json
from bs4 import BeautifulSoup
import re
import sys
reload(sys)
sys.setdefaultencoding('utf8')
def getlrc(artist, title, neid):
requrl="http://lp.music.ttpod.com/lrc/down?artist=" + artist + "&title=" + title + "&code=" +str( neid);
req=urllib2.urlopen(requrl)
rsp=req.read()
jsonstr=json.loads(rsp)
print(jsonstr['data']['lrc'])
def searchsong(songname,artiestname):
requrl='http://so.ard.iyyin.com/search.do?q='+songname+'+'+artiestname
req=urllib2.urlopen(requrl)
rsp=req.read()
#encodejson=json.dumps(rsp)
jsonstr=json.loads(rsp)
#print(jsonstr['data'])
neid=jsonstr['data'][0]['neid']
print(neid)
getlrc(artiestname,songname,neid)
def useragent(url):
i_headers = {"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) \
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36", \
"Referer": 'http://baidu.com/'}
req = urllib2.Request(url, headers=i_headers)
html = urllib2.urlopen(req).read()
return html
def xiamisearch(songname,artiestname):
requrl='http://www.xiami.com/search/song-lyric?key='+artiestname+'+'+songname
rsp=useragent(requrl)
soup=BeautifulSoup(rsp)
div=soup.find("div", { "class" : "all_LRC" })
table=div.find("table", { "class" : "track_list" })
inputvalue=table.find(['input'])['value']
print(inputvalue)
xiamilrc(inputvalue)
def xiamilrc(value):
requrl='http://www.xiami.com/song/playlist/id/'+value
#print requrl
rsp=useragent(requrl)
#print rsp
lrcid = re.compile('<lyric_url>(.*?)</lyric_url>',re.S).findall(rsp)
print lrcid[0]
if __name__=='__main__':
#searchsong('我什么都没有','陈奕迅')
xiamisearch('我什么都没有','陈奕迅')
"""
lrc=SetLrc()
lrc.ClearLrc()
zhihu=MyZhiHu()
zhihu.login()
zhihu.GetCollection()
"""
print('the end')
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/lylinux/python.git
git@gitee.com:lylinux/python.git
lylinux
python
python
master

搜索帮助