#https://www.ximalaya.com/yinyue/
#更改後面網址以對應欲爬取內容
import requests
from lxml import etree
class Spider(object):
def __init__(self):
self.headers = {'User-Agent':"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50"}
def GetReponce(self,url):
reponce = requests.get(url, headers=self.headers)
return reponce
def Main(self,reponce,id):
try:
list =[]
htmls = etree.HTML(reponce.text)
datas = htmls.xpath("//a[@class='album-title line-1 lg bold _kC']")
for data in datas:
tits = data.xpath('./@title')
href = data.xpath('./@href')
id+=1
list.append("id("+str(id)+'):'+