資源簡(jiǎn)介
代碼片段和文件信息
from?selenium?import?webdriver
import?csv
from?selenium.webdriver.chrome.options?import?Options
chrome_options?=?Options()
chrome_options.add_argument(‘--headless‘)
chrome_options.add_argument(‘--disable-gpu‘)
driver?=?webdriver.Chrome(options=chrome_options)
url1?=?‘http://music.163.com/#/discover/playlist/?order=hot&cat=%E5%85%A8%E9%83%A8&limit=35&offset=‘
offset?=?0
#準(zhǔn)備好存儲(chǔ)歌單的csv文件
csv_file?=?open(“playlist.csv“‘w‘newline=‘‘)
writer?=?csv.writer(csv_file)
writer.writerow([‘標(biāo)題‘‘播放數(shù)‘‘鏈接‘])
#解析每一頁(yè),直到‘下一頁(yè)’為空
for?page?in?range(2):
????print(‘\n???正在爬取第%d頁(yè)。。?!?page‘\n‘)
????url?=?url1+str(offset)
????offset?=?offset+35
????print(‘??‘url?‘\n‘)
????#用webDriver加載頁(yè)面
- 上一篇:openmv二維碼識(shí)別
- 下一篇:微信聊天機(jī)器人(基于wxpy)
評(píng)論
共有 條評(píng)論