def foucs_friend(self, url, webdriver):
     webdriver.get(url)
     webdriver.implicitly_wait(10)
     nums = FriendHomePage.get_friend_info(webdriver)
     foucs_nums = nums[0]
     fans_num = nums[1]
     if foucs_nums/fans_num > 0.5:
         FriendHomePage.focus_action(webdriver)
         time.sleep(3)
     else:
         print '不符合要求,不于关注'
 def foucs_friend(self, url, webdriver):
     webdriver.get(url)
     webdriver.implicitly_wait(10)
     nums = FriendHomePage.get_friend_info(webdriver)
     foucs_nums = nums[0]
     fans_num = nums[1]
     if foucs_nums / fans_num > 0.5:
         FriendHomePage.focus_action(webdriver)
         time.sleep(3)
     else:
         print '不符合要求,不于关注'
Beispiel #3
0
 def focus_check(self, fans_driver, address):
     fans_info = FriendHomePage.get_friend_info(fans_driver)
     focus_num = fans_info[0]
     fans_num = fans_info[1]
     weibo_num = fans_info[2]
     return focus_num < 500 and fans_num < 5000 and weibo_num > 20 and '南京' in address[
         1]
Beispiel #4
0
    def search(self, fans_driver):
        print(self.visited_url)
        try:

            if fans_driver.current_url in self.visited_url:
                print fans_driver.current_url
                print('存在')
                return
            self.visited_url.add(fans_driver.current_url)
            address = FriendHomePage.address(fans_driver)
            username = FriendHomePage.user_name(fans_driver)
            if not '江苏' in address[0]:
                print('不在江苏')
                print(address[0])
                print(fans_driver.current_url)
                return
            if self.focus_check(fans_driver, address):
                FriendHomePage.focus_friend_action(fans_driver)
            fans_url = []
            while self.last_weibo_in_time:
                fans_url.extend(self.weibo_list(fans_driver, username))
                try:
                    WeiboPageCommon.next_page_action(fans_driver)
                except Exception as e:
                    print(e)
                    break

            print ''
            #搜索关注列表
            FriendHomePage.focus_action(fans_driver)
            focus_fans_list = FriendFoucsPage.fans_list_parsed(fans_driver)
            #搜索粉丝列表
            FriendFoucsPage.fans_action(fans_driver)
            fans_list = FriendFoucsPage.fans_list_parsed(fans_driver)
            focus_fans_list.extend(fans_list)
            url_list = []
            for fans in focus_fans_list:
                if '江苏' in fans.address[0]:
                    url_list.append(fans.href)

            fans_url.extend(url_list)
            fans_url = set(fans_url)
            self.un_visited_url = fans_url
            with open(self.un_visited_url_file_name, 'w') as file:
                pickle.dump(self.un_visited_url, file)
                print '保存未访问url'
            for url in fans_url:
                fans_driver.get(url)
                fans_driver.implicitly_wait(10)
                self.search(fans_driver)
                self.visited_url.add(url)
                self.un_visited_url.remove(url)
            with open(self.visited_url_file_name, 'w') as file:
                pickle.dump(self.visited_url, file)
                print '保存访问url'

        except Exception as e:
            print e
            return
Beispiel #5
0
 def __get_weiboer_info(self, weibo):
     try:
         print('访问:'),
         print(weibo.author_url)
         self.browser.get(weibo.author_url)
         time.sleep(4)
         info = FriendHomePage.get_friend_info(self.browser)
         fans_info = FansInfo()
         fans_info.focus_num = info[0]
         fans_info.fans_num = info[1]
         fans_info.weibo_num = info[2]
         weibo.author_info = fans_info
         pass
     except Exception as e:
         pass
            comment = WeiboPageCommon.comment_parse(comment_list[0])
            url = comment[0]
            return url

    def focuos(self, webdriver):
        TopFrameAction.homeAction(webdriver)
        focus_box = webdriver.find_element_by_id('Pl_Core_T8CustomTriColumn__3')
        focus_box.find_element_by_link_text("关注").click()

if __name__ == '__main__':
    weibo = LoginController('13951640490', 'gongyong505.')
    weibo.login()
    time.sleep(5)
    weibo.browser.get('http://weibo.com/545352510')
    time.sleep(3)
    FriendHomePage.focus_action(weibo.browser)
    FocusPage.next_page_action(weibo.browser)
    f = FollowShipControl()
    f.fouces_friend_of_comment(weibo.browser)
    weibo_list = WeiboPageCommon.get_all_weibo(weibo.browser)
    time.sleep(3)
    for weibo_driver in weibo_list:
        wei = WeiboPageCommon.weibo_parse(weibo_driver)
        if wei.comment_num > 0:
            WeiboPageCommon.comment_action(weibo_driver)
            comment_list = WeiboPageCommon.comment_list(weibo_driver)
            comment = WeiboPageCommon.comment_parse(comment_list[0])
            url = comment[0]
            weibo.browser.get(url)
            FriendHomePage.focus_action(weibo.browser)
            break
Beispiel #7
0
 def search_check(self, fans_driver):
     address = FriendHomePage.address(fans_driver)
     return '江苏' in address[0]
            return url

    def focuos(self, webdriver):
        TopFrameAction.homeAction(webdriver)
        focus_box = webdriver.find_element_by_id(
            'Pl_Core_T8CustomTriColumn__3')
        focus_box.find_element_by_link_text("关注").click()


if __name__ == '__main__':
    weibo = LoginController('13951640490', 'gongyong505.')
    weibo.login()
    time.sleep(5)
    weibo.browser.get('http://weibo.com/545352510')
    time.sleep(3)
    FriendHomePage.focus_action(weibo.browser)
    FocusPage.next_page_action(weibo.browser)
    f = FollowShipControl()
    f.fouces_friend_of_comment(weibo.browser)
    weibo_list = WeiboPageCommon.get_all_weibo(weibo.browser)
    time.sleep(3)
    for weibo_driver in weibo_list:
        wei = WeiboPageCommon.weibo_parse(weibo_driver)
        if wei.comment_num > 0:
            WeiboPageCommon.comment_action(weibo_driver)
            comment_list = WeiboPageCommon.comment_list(weibo_driver)
            comment = WeiboPageCommon.comment_parse(comment_list[0])
            url = comment[0]
            weibo.browser.get(url)
            FriendHomePage.focus_action(weibo.browser)
            break