def getCurPageSta(self, sleepDure): retval = [] staElems = PageDriver.getStaElems(self.mDriver) addidx = 0 while True: if len(staElems) > addidx: PageDriver.rollTo(driver=self.mDriver, elem=staElems[addidx]) time.sleep(sleepDure) sta = StPage.st_status() sta.id = PageDriver.getMid(staElems[addidx]) sta.idstr = str(sta.id) sta.mid = sta.id sta.created_at = PageDriver.getTime(staElems[addidx]) sta.reposts_count = PageDriver.getRepostsCount(staElems[addidx]) sta.comments_count = PageDriver.getCommentCount(staElems[addidx]) sta.text = PageDriver.getText(staElems[addidx]) #print(sta.text.encode('gbk', 'ignore')) retval.append(sta) addidx += 1 else:#equals staElems = PageDriver.getStaElems(self.mDriver) if len(staElems) == addidx: break return retval
def goNextPage(self): return PageDriver.goNextPage(driver=self.mDriver)
def gotoPeople(self, peopleNum): PageDriver.gotoPeople(iden=peopleNum, driver=self.mDriver)
def gotoPage(self, pageAddr): PageDriver.gotoPage(page=pageAddr, driver=self.mDriver)
def __init__(self, username, password): self.mDriver = webdriver.Chrome() self.mDriver.get('http://www.weibo.com') PageDriver.login(driver=self.mDriver, usernm=username, passwd=password) time.sleep(4)