コード例 #1
0
ファイル: SearchPage.py プロジェクト: hjydzh/weiboCrawler
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
コード例 #2
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
コード例 #3
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
コード例 #4
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