代码拉取完成,页面将自动刷新
一
import requests
from lxml import etree
url = 'http://www.sucaijishi.com/icon/'
res = requests.get(url)
res.encoding = res.apparent_encoding
#print(res.status_code)
#print(res.text)
ehtml = etree.HTML(res.text)
title = ehtml.xpath('//div[@class="w1180px common_list pt150"]//img/@src')
respic = requests.get(title[0])
print(respic.content)
pic = '测试图片.png'
with open(pic,'wb') as f:
f.write(respic.content)
#wz1 = ehtml.xpath('//p[@class="title ellipsis2"]/text()')
#print(wz1)
二
import request
from lxml import etree
url = 'https://www.ximalaya.com/yinyue/54070700/'
header = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.0.8793 Safari/537.36'
}
res =res.get(url,headers=header)
print(res.status_code)
ehtml = etree.HTML(res.text)
title = ehtml.xpath('//div[@class="text Mi_"]/a/@href')
print(title)
for i in title:
id = i.split("/")[-1]
murl = 'https://www.ximalaya.com/revision/play/v1/audio?id' + id +'&ptype=1'
ires = request.get(murl,headers=header)
musicUrl = ires.json()['data']['src']
mres = request.get(musicUrl,headers=header)
filename = id + ".mp3"
with open(filename,'wb') as f:
f.write(mres.content)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。