TA的每日心情 | 无聊 前天 09:47 |
---|
签到天数: 528 天 连续签到: 1 天 [LV.9]测试副司令
|
1测试积点
问题遇到的现象和发生背景
无法获取全部数据,不知道文章和粉丝之间的页面的数据怎么进行连接
- from selenium import webdriver
- import random
-
- from selenium.webdriver.common.keys import Keys
- import time
- import re
-
-
- # user_ = input('请输入账号:')
- # password = input('请输入密码:')
- url = "https://weibo.com/login.php"
- dirver = webdriver.Chrome()
- dirver.get(url)
- time.sleep(0.5)
- dirver.maximize_window()
-
-
- dirver.find_element_by_id('loginname').send_keys('18327862307')
- time.sleep(2)
-
-
- dirver.find_element_by_xpath('//*[@id="pl_login_form"]/div/div[3]/div[2]/div/input').send_keys('love572461914')
- time.sleep(2)
- dirver.find_element_by_xpath('//*[@id="pl_login_form"]/div/div[3]/div[6]/a').click()
- time.sleep(20)
-
- # 登录进入六星网页
- url_six = "https://weibo.com/liuxingedu"
- dirver.get(url_six)
- time.sleep(2)
- # dirver.find_element_by_xpath('//*[@id="__sidebar"]/div/div[1]/div/div[2]/div/div[1]/div[1]/div[2]/div[2]').click()
-
- # 进行页面滚动
- for i in range(1,1000):
- js="var q=document.documentElement.scrollTop=%s"%(i*300)
- time.sleep(0.3)
- dirver.execute_script(js)
-
- # 获取文章内容
- title_url = "https://weibo.com/ajax/statuses/mymblog?uid=7617227236&page=1&feature=0"
- dirver.get(title_url)
- titles = dirver.find_elements_by_xpath('//*[@id="app"]/div[1]/div[2]/div[2]/main/div[1]/div/div[2]/div[2]')
- for title in titles:
- print(1,title.text)
-
- # 点击进入粉丝页
- dirver.find_element_by_xpath('//*[@id="app"]/div[1]/div[2]/div[2]/main/div[1]/div/div[2]/div[1]/div[1]/div[2]/div[2]/div[2]/a[1]').click()
-
- fans_url = 'https://weibo.com/u/page/follow/7617227236?relate=fans'
- dirver.get(fans_url)
- fans_list = []
- fans_nums = dirver.find_elements_by_class_name('vue-recycle-scroller__item-view')
- for fans in fans_nums:
- f_dict = {fans}
- fans_list.append(f_dict)
- print(fans_list)
-
- # 进行页面滚动
- for i in range(1,1000):
- js="var q=document.documentElement.scrollTop=%s"%(i*300)
- time.sleep(0.3)
- dirver.execute_script(js)
复制代码
|
|