예제 #1
0
 def get_to_mood_page(self):
     #本函数用于登录QQ空间并跳转至说说界面
     
     driver = self.driver
     #访问QQ空间
     driver.get('https://i.qq.com')
     #print('geted')
     
     #输入账户密码的frame不是默认的frame 所以需要更改frame 不然找不到元素
     driver.switch_to.frame('login_frame')
     #print('switched')
     
     #显示等待id为switcher_plogin的按钮,该按钮用于更改登录方式为账号密码登录
     switch = WebWait(driver,5).until(EC.element_to_be_clickable((By.ID,'switcher_plogin')))
     switch.click()
     #print('clicked')
     
     #找到输入账号和密码的文本框并输入账号密码
     driver.find_element_by_id('u').send_keys(moodSpider.user)
     driver.find_element_by_id('p').send_keys(moodSpider.passwd)
     login = WebWait(driver,5).until(EC.element_to_be_clickable((By.ID,'login_button')))
     login.click()
     
     #登录后跳转至说说界面
     time.sleep(2)
     driver.get('http://user.qzone.qq.com/'+moodSpider.user+'/311')
예제 #2
0
 def to_next_page(self):
 
     driver = self.driver
     #此函数用于跳转至下一页
     #因为下一页的id是会变化的,所以在文本里识别出来下一页的id
     soup = self.soup
     next_page_id = soup.find('a',{'title':'下一页'})['id']
     to_next = WebWait(driver,5).until(EC.element_to_be_clickable((By.ID,next_page_id)))
     to_next.click()
     driver.switch_to.parent_frame()
     
     #翻页后返回顶端,以保证所以的说说被加载
     driver.execute_script('window.scrollBy(0,-10000)')
     time.sleep(1)
     driver.execute_script('window.scrollBy(0,-10000)')
     time.sleep(1)
     driver.execute_script('window.scrollBy(0,-10000)')
     time.sleep(1)
예제 #3
0
 def wait_2(self):
     WebWait(self.driver, 10).until(
         ex_co.presence_of_element_located((By.ID, self.email_id)))
예제 #4
0
 def wait(self):
     WebWait(self.driver, 10).until(
         ex_co.element_to_be_clickable(
             (By.LINK_TEXT, self.checkout_link_text)))
예제 #5
0
 def wait(self):
     WebWait(self.driver, 5).until(ex_co.element_to_be_clickable((By.PARTIAL_LINK_TEXT, self.product_link_text)))
예제 #6
0
 def wait(self):
     WebWait(self.driver, 5).until(
         ex_co.element_to_be_clickable((By.NAME, self.submit_button)))