selenium:周杰倫の歌詞

3609 ワード

爬虫類の練習1:周杰倫の歌評


QQ音楽の前の30条の热评*を登って、ついでにどのようにCSDNブログを発见します*
import time
import re
from selenium import webdriver 

driver = webdriver.Chrome()
driver.get('https://y.qq.com/n/yqq/song/000xdZuV2LcQ19.html') 
time.sleep(2)

button = driver.find_element_by_class_name('js_get_more_hot') 【 】
button.click() 
time.sleep(2)

pageSource = driver.page_source
# str 
pattern = re.compile(r'

(.*?)

'
, re.S|re.M) results = re.findall(pattern, pageSource) for result in results[0:30]: # 30 result1 = re.sub(r'','',result) # emoji print(result1.strip()) print('-----------------') driver.close()

学習過程を純粋に記録する