我正在尝试从http://los40.com.ar/lista40/下载所有歌曲列表,我可以手动下载,但我想自动执行该过程。首先,我提取了附有美丽汤的溃疡,但是我无法浏览结果
例如,这是列表中的第一首歌曲:
var datos_cancion_1 = Array();
datos_cancion_1['url_audioenci'] = 'https://recursosweb.prisaradio.com/audios/dest/010002713547.mp4';
datos_cancion_1['url_muzu'] = '';
datos_cancion_1['url_youtube'] = 'https://www.youtube.com/watch?v=0S3enulCT8E';
datos_cancion_1['url_itunes'] = '';
datos_cancion_1['posicion'] = '1';
datos_cancion_1['url_caratula'] = 'https://recursosweb.prisaradio.com/fotos/dest/010002713548.jpg';
datos_cancion_1['titulo_cancion'] = '22';
datos_cancion_1['nombre_artista'] = 'Greeicy;Tini';
datos_cancion_1['idYes'] = 'Tini';
datos_cancion_1['VidAu'] = 0;
我想获得一个数组或json,例如:['https://recursosweb.prisaradio.com/audios/dest/010002713547.mp4','https://recursosweb.prisaradio.com/fotos/dest/010002713548.jpg,Greeicy;Tini] [datos_cancion_1 ['url_audioenci'],datos_cancion_1 ['url_caratula'],]
这是我的代码,希望您能为我提供帮助:
from bs4 import BeautifulSoup
import requests
import json
import re
import urllib
url = 'http://los40.com.ar/m/lista40/'
videos = []
response = requests.get(url)
bs = BeautifulSoup(response.text,"html.parser")
all_script=bs.find_all('script', language='javascript', type='text/javascript')
data=all_script[8:]
a= data[0].string
b=['https://recursosweb.prisaradio.com/audios/dest/010002713547.mp4','https://recursosweb.prisaradio.com/fotos/dest/010002713548.jpg','Greeicy;Tini', datos_cancion_1['nombre_artista'] ]
print(a)
urllib.request.urlretrieve(b[0],b[2] +'.mp3')
答案 0 :(得分:0)
您可以尝试以下方法:
song_list = [''.join(' '.join(i.text.split('\n')).split('=')).split(';') for i in data]
这将为您提供一个数组,每个数组都是这样的:
["'https://recursosweb.prisaradio.com/audios/dest/010002696230.mp4'",
" datos_cancion_2['url_muzu'] ''",
" datos_cancion_2['url_youtube'] "
"'https://www.youtube.com/watch?v1Jw_mhoCiFY'",
" datos_cancion_2['url_itunes'] ''",
" datos_cancion_2['posicion'] '2'",
" datos_cancion_2['url_caratula'] "
"'https://recursosweb.prisaradio.com/fotos/dest/010002696233.jpg'",
" datos_cancion_2['titulo_cancion'] 'Cristina'",
" datos_cancion_2['nombre_artista'] 'Sebastián Yatra'",
" datos_cancion_2['idYes'] 'Sebastian-Yatra'",
" datos_cancion_2['VidAu'] 0",
' ']
从这里开始,我认为您将能够根据需要订购最终阵列。
希望这对您有所帮助。