資源簡介
使用Python,使用火狐瀏覽器(可根據自己的瀏覽器修改代碼)作為下載瀏覽器,下載網易云音樂。基于Tkinter設計的一款音樂下載器源碼文件。源碼分析見:https://blog.csdn.net/qq_36477513/article/details/104823247;源碼見:https://download.csdn.net/download/qq_36477513/12244493
代碼片段和文件信息
#?網易云音樂下載器
#?import?requests
#?url=‘https://music.163.com/#/search/m/?s=%E8%BF%9D%E7%AB%A0%E5%8A%A8%E7%89%A9&type=1‘
#?res?=?requests.get(url)靜態頁面爬取
from?selenium?import?webdriver
import?os
#?保存網頁內容到文件
from?urllib.request?import?urlretrieve
from?tkinter?import?*
#?爬取音樂(動態頁面)
#?搜索函數
def?get_music_name():
????#?獲取歌曲名稱
????name=entry.get()
????url=‘https://music.163.com/#/search/m/?s={}&type=1‘.format(name)
????#?隱藏瀏覽器
????option=webdriver.FirefoxOptions()
????option.add_argument(‘--headless‘)
????driver=webdriver.Firefox(firefox_options=option)
????#?搜索歌曲頁面
????#?driver?=?webdriver.Firefox()
????driver.get(url)
????#?根據id查詢到標簽
????driver.switch_to.frame(‘g_iframe‘)
????#?獲取歌曲id
????res?=?driver.find_element_by_id(‘m-search‘)
????music_url?=?res.find_
- 上一篇:爬取高德地圖交通態勢
- 下一篇:用python編寫的個人博客源碼
評論
共有 條評論