예제 #1
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
예제 #2
0
def __focus_parse(focus_driver):
    fans = FansInfo()
    wrapper_driver = focus_driver.find_element_by_xpath(
        ".//a[@node-type='screen_name']")
    fans.id = wrapper_driver.get_attribute('usercard').encode('utf-8')[3:]
    fans.name = wrapper_driver.get_attribute('title').encode('utf-8')
    fans.href = wrapper_driver.get_attribute('href').encode('utf-8')
    fans.driver = focus_driver
    relationship = focus_driver.find_element_by_class_name(
        'statu').text.encode('utf-8')
    if relationship == '互相关注':
        fans.relationship = CommonConst.Const.FOCUS_EACH_OTHER
    else:
        fans.relationship = CommonConst.Const.ME_FOCUS_HIM
    return fans
예제 #3
0
def show_fans_info(weibo_driver, webdriver):
    img_driver = weibo_driver.find_element_by_xpath(".//div[@class='WB_face W_fl']").find_element_by_tag_name('img')
    ActionChains(webdriver).move_to_element(img_driver).perform()
    webdriver.implicitly_wait(4)
    fans_info = FansInfo()
    fans_info_driver = webdriver.find_element_by_class_name('layer_personcard')
    fans_nums_info_driver = fans_info_driver.find_element_by_class_name('c_count').find_elements_by_tag_name('em')
    print fans_nums_info_driver[0].text.encode('utf-8').strip()
    fans_info.focus_num = int(fans_nums_info_driver[0].text.encode('utf-8').strip())
    fans_info.fans_num = fans_nums_info_driver[1].text.encode('utf-8')
    if '万' in fans_info.fans_num:
        fans_info.fans_num = int(fans_info.fans_num.strip()[:-3] + '0000')
    else:
        fans_info.fans_num = int(fans_info.fans_num.strip())
    fans_info.weibo_num = int(fans_nums_info_driver[2].text.encode('utf-8').strip())
    fans_info.name = fans_info_driver.find_element_by_class_name('W_f14').get_attribute('title').encode('utf-8')
    fans_info.gender = fans_info_driver.find_element_by_tag_name('em').get_attribute('title').encode('utf-8')
    return fans_info
예제 #4
0
def show_fans_info(weibo_driver, webdriver):
    img_driver = weibo_driver.find_element_by_xpath(
        ".//div[@class='WB_face W_fl']").find_element_by_tag_name('img')
    ActionChains(webdriver).move_to_element(img_driver).perform()
    webdriver.implicitly_wait(4)
    fans_info = FansInfo()
    fans_info_driver = webdriver.find_element_by_class_name('layer_personcard')
    fans_nums_info_driver = fans_info_driver.find_element_by_class_name(
        'c_count').find_elements_by_tag_name('em')
    print fans_nums_info_driver[0].text.encode('utf-8').strip()
    fans_info.focus_num = int(
        fans_nums_info_driver[0].text.encode('utf-8').strip())
    fans_info.fans_num = fans_nums_info_driver[1].text.encode('utf-8')
    if '万' in fans_info.fans_num:
        fans_info.fans_num = int(fans_info.fans_num.strip()[:-3] + '0000')
    else:
        fans_info.fans_num = int(fans_info.fans_num.strip())
    fans_info.weibo_num = int(
        fans_nums_info_driver[2].text.encode('utf-8').strip())
    fans_info.name = fans_info_driver.find_element_by_class_name(
        'W_f14').get_attribute('title').encode('utf-8')
    fans_info.gender = fans_info_driver.find_element_by_tag_name(
        'em').get_attribute('title').encode('utf-8')
    return fans_info
예제 #5
0
def fans_parse(fans_driver):
    print('解析关注中的好友列表')
    href = fans_driver.find_element_by_class_name('S_txt1').get_attribute(
        'href')
    nums_driver = fans_driver.find_elements_by_class_name('count')
    focus_num = nums_driver[0].text
    fans_num = nums_driver[1].text
    weibo_num = nums_driver[2].text
    address = fans_driver.find_element_by_class_name(
        'info_add').find_element_by_tag_name('span').text.encode(
            'utf-8').split(' ')
    country = address[0]
    if len(address) > 1:
        city = address[1]
    else:
        city = ''
    address = (country, city)
    fans = FansInfo()
    fans.href = href
    fans.focus_num = focus_num
    fans.fans_num = fans_num
    fans.weibo_num = weibo_num
    fans.address = address
    return fans
예제 #6
0
def fans_parse(fans_driver):
    print('解析关注中的好友列表')
    href = fans_driver.find_element_by_class_name('S_txt1').get_attribute('href')
    nums_driver = fans_driver.find_elements_by_class_name('count')
    focus_num = nums_driver[0].text
    fans_num = nums_driver[1].text
    weibo_num = nums_driver[2].text
    address = fans_driver.find_element_by_class_name('info_add').find_element_by_tag_name('span').text.encode('utf-8').split(' ')
    country = address[0]
    if len(address) > 1:
        city = address[1]
    else:
        city = ''
    address = (country, city)
    fans = FansInfo()
    fans.href = href
    fans.focus_num = focus_num
    fans.fans_num = fans_num
    fans.weibo_num = weibo_num
    fans.address = address
    return fans
예제 #7
0
def person_info_parse(person_driver):
    name = person_driver.find_element_by_class_name('person_name').text
    href = person_driver.find_element_by_class_name('person_addr').find_element_by_class_name('W_linkb').text
    person_addr_driver = person_driver.find_element_by_class_name('person_addr').find_elements_by_tag_name('span')
    gender = person_addr_driver[0].get_attribute('title')
    address = person_addr_driver[1].text.encode('utf-8').split(',')[1]
    person_num_driver = person_driver.find_element_by_class_name('person_num').find_elements_by_tag_name('a')
    focus_num = int(person_num_driver[0].text)
    fans_num = int(person_num_driver[1].text)
    weibo_num = int(person_num_driver[2].text)
    infos = info_parse(person_driver)
    company = infos.get('职业信息')
    edu = infos.get('教育信息')
    person_info = FansInfo()
    person_info.name = name
    person_info.address = address
    person_info.company = company
    person_info.edu = edu
    person_info.gender = gender
    person_info.href = href
    person_info.focus_num = focus_num
    person_info.fans_num = fans_num
    person_info.weibo_num = weibo_num
    person_info.focus_action = person_driver.find_element_by_class_name('person_adbtn').find_elements_by_tag_name('a')
    return person_info
예제 #8
0
def person_info_parse(person_driver):
    name = person_driver.find_element_by_class_name('person_name').text
    href = person_driver.find_element_by_class_name(
        'person_addr').find_element_by_class_name('W_linkb').text
    person_addr_driver = person_driver.find_element_by_class_name(
        'person_addr').find_elements_by_tag_name('span')
    gender = person_addr_driver[0].get_attribute('title')
    address = person_addr_driver[1].text.encode('utf-8').split(',')[1]
    person_num_driver = person_driver.find_element_by_class_name(
        'person_num').find_elements_by_tag_name('a')
    focus_num = int(person_num_driver[0].text)
    fans_num = int(person_num_driver[1].text)
    weibo_num = int(person_num_driver[2].text)
    infos = info_parse(person_driver)
    company = infos.get('职业信息')
    edu = infos.get('教育信息')
    person_info = FansInfo()
    person_info.name = name
    person_info.address = address
    person_info.company = company
    person_info.edu = edu
    person_info.gender = gender
    person_info.href = href
    person_info.focus_num = focus_num
    person_info.fans_num = fans_num
    person_info.weibo_num = weibo_num
    person_info.focus_action = person_driver.find_element_by_class_name(
        'person_adbtn').find_elements_by_tag_name('a')
    return person_info