selenium获取微博用户粉丝数
selenum的安装
selenium文档
获取微博用户粉丝数
from selenium import webdriver from time import sleep wd = webdriver.Chrome("D:\program\chromedriver_win32\chromedriver.exe") wd.maximize_window() wd.implicitly_wait(15) # 打开微博首页 wd.get("https://weibo.com/") # 选中搜索框,输入检索内容,点击搜搜 searchInput = wd.find_element_by_css_selector('#weibo_top_public > div > div > div.gn_search_v2 > input') searchBtn = wd.find_element_by_css_selector('#weibo_top_public > div > div > div.gn_search_v2 > a') searchInput.send_keys("燕十八") searchBtn.click() # 进入新页面,设置新句柄 print(wd.title) ysbLink = wd.find_element_by_css_selector('#pl_feed_main > div.m-wrap > div.m-con-r > div:nth-child(1) > div > div.card-content.s-pg12 > div:nth-child(1) > div.info > div > a') ysbLink.click() # 获取粉丝数目 follow = wd.find_element_by_css_selector('#Pl_Core_T8CustomTriColumn__3 > div > div > div > table > tbody > tr > td:nth-child(1) > a > strong') fans = wd.find_element_by_css_selector('#Pl_Core_T8CustomTriColumn__3 > div > div > div > table > tbody > tr > td:nth-child(2) > a > strong') weiboNum = wd.find_element_by_css_selector('#Pl_Core_T8CustomTriColumn__3 > div > div > div > table > tbody > tr > td:nth-child(3) > a > strong') print("关注数:"+follow.text) print("粉丝数:"+fans.text) print("微博书:"+weiboNum.text) sleep(3) wd.close()
相关推荐
xiangxiaojun 2020-09-23
Reiki 2020-08-16
letheashura 2020-08-14
tiankele0 2020-07-29
curiousL 2020-07-18
王练 2020-07-18
tiankele0 2020-07-18
amei0 2020-07-08
Reiki 2020-07-06
Ronnyxie 2020-07-06
xiangxiaojun 2020-07-05
zhanghaibing00 2020-06-28
xiongyouqiang 2020-06-28
Ronnyxie 2020-06-27
amei0 2020-06-26
letheashura 2020-06-26
tiankele0 2020-06-26
王练 2020-06-25