# -*- coding: utf-8 -*- import time from selenium import webdriver # 下拉加载页面 def scroll_foot(driver): js="var q=document.documentElement.scrollTop=100000" return driver.execute_script(js) # gid后面写自己要爬取的群号 url = "https://qun.qq.com/member.html#gid=554590815" driver = webdriver.Chrome() driver.get(url) # 要往下滑动的次数,要滑动几次就写几次循环,群成员多要多下滑 for i in range(3): scroll_foot(driver) time.sleep(1) # 爬出总的扣扣信息 elements = driver.find_elements_by_css_selector('tbody.list > tr.mb') for element in elements: # print(element.text) name = element.find_element_by_css_selector('td.td-user-nick span').text QQs = element.find_elements_by_css_selector('td') data = {} data['昵称'] = QQs[2].text data['QQ号'] = QQs[4].text data['性别'] = QQs[5].text data['Q龄'] = QQs[6].text data['入群时间'] = QQs[7].text data['最后发言'] = QQs[9].text print(data) if data: pass# 存入csv中及其他操作
python应用selenium爬取qq群中所有成员信息
阅读:3731 输入:2020-06-04 22:32:02
- 上一篇:js实现复返框选择,反选
- 下一篇:js实现dom操作表格的动态新增与删除