微博热榜
#@Time : 2020/10/25 20:34
#@Author : 桃子猫的布偶
#@Software: PyCharm
from selenium import webdriver
driver=webdriver.Chrome("D:/python/chromedriver.exe")
driver.get("https://m.weibo.cn/")
driver.implicitly_wait(3)
driver.find_element_by_css_selector(".m-search").click()
driver.find_element_by_css_selector("div.card-main div.m-item-box:nth-last-child(1) h4").click()
listType = driver.find_elements_by_css_selector(".card.card11")
for oneType in listType:
cStr = oneType.find_element_by_css_selector("h2.card-title")
if "实时热点,每分钟更新一次" not in cStr.text:
continue
list = oneType.find_elements_by_css_selector(".card-list .card.m-panel.card4")
for one in list:
contStr = one.find_element_by_css_selector(".main-text.m-text-cut")
try:
imgStr = one.find_element_by_css_selector(".m-link-icon img")
imgUrl = imgStr.get_attribute("src")
if "hot" in imgUrl:
print("hot", contStr.text)
elif "new" in imgUrl:
print("new", contStr.text)
elif "fei" in imgUrl:
print("fei", contStr.text)
except:
pass
打印结果演示
hot 五中全会公报20个表述
new 双阴性证明
hot 张雨绮没有一个音在调上
new 吴亦凡发长文告别新说唱
fei 赵露思
fei 教资
new 厄瓜多尔进口冷冻鲳鱼检出新冠阳性
new 万圣节幼儿园的小朋友
new 瑞典人揭秘鲱鱼罐头正确吃法
new 爱琴海地震致12人死亡数百人受伤
new 留学回国人员证明取消
new SM新女团aespa团体照
new 姐姐的爱乐之程周震南镜头
new 意大利酒吧老板当街倒啤酒抗议封锁
new 男同学解出数学题表情超兴奋
new 美商务部TikTok技术交易禁令暂缓执行
new 志愿军日夜修桥真实画面
new 中国造地铁成巴基斯坦热门打卡地
Process finished with exit code 0