Beispiel #1
0
def _fetch_details(url):
    """Fetch and parse person's details. User profile's URL must be
    provided.
    """
    soup = connect(url)
    data = dict()
    # Get full name.
    data['first_name'] = cleanstr(soup.find(class_='given-name').string)
    data['last_name'] = cleanstr(soup.find(class_='family-name').string)
    title_tag = soup.find(class_='headline-title')
    if title_tag is not None:
        list_ = title_tag.string.split(' at ')
        # Get company name.
        if len(list_) == 2:
            data['company'] = cleanstr(list_[1])
        # Get position.
        position = cleanstr(list_[0])
        if position != '--':
            data['position'] = position
    # Get location.
    location_tag = soup.find(class_='locality')
    if location_tag is not None:
        location_list = location_tag.string.split(',')
        if len(location_list) == 2:
            data['city'] = cleanstr(location_list[0])
        data['country'] = cleanstr(location_list[-1])
    # Get industry.
    industry = soup.find(class_='industry')
    if industry is not None:
        data['industry'] = cleanstr(industry.string)
    return data
Beispiel #2
0
def _fetch_details(url):
    """Fetch and parse person's details. User profile's URL must be
    provided.
    """
    soup = connect(url)
    data = dict()
    # Get full name.
    data['first_name'] = cleanstr(soup.find(class_='given-name').string)
    data['last_name'] = cleanstr(soup.find(class_='family-name').string)
    title_tag = soup.find(class_='headline-title')
    if title_tag is not None:
        list_ = title_tag.string.split(' at ')
        # Get company name.
        if len(list_) == 2:
            data['company'] = cleanstr(list_[1])
        # Get position.
        position = cleanstr(list_[0])
        if position != '--':
            data['position'] = position
    # Get location.
    location_tag = soup.find(class_='locality')
    if location_tag is not None:
        location_list = location_tag.string.split(',')
        if len(location_list) == 2:
            data['city'] = cleanstr(location_list[0])
        data['country'] = cleanstr(location_list[-1])
    # Get industry.
    industry = soup.find(class_='industry')
    if industry is not None:
        data['industry'] = cleanstr(industry.string)
    return data
Beispiel #3
0
def _fetch_details(url):
    """Fetch and parse company's details."""
    print("Connecting to {}".format(url))
    soup = connect(url)
    data = dict()
    # Get company name.
    cont = soup.find(id='result')
    if cont is not None:
        name_tag = cont.find('h2')
        if name_tag is not None:
            data['name'] = cleanstr(cont.find('h2').string)
        table = cont.find('table')
        if table is not None:
            rows = table.find_all('tr')
            if len(rows) > 1:
                row = rows[1]
                for col in row.children:
                    if istag(col):
                        s = str()
                        for el in col.contents:
                            if el.string is not None:
                                if istag(el):
                                    s += cleanstr(el.string)
                                else:
                                    s += cleanstr(el)
                        if 'Tel:' in s:
                            # Get phone number.
                            phone = ''
                            for d in s[5:17]:
                                if d.isdigit():
                                    phone += d
                            if len(phone) == 10:
                                data['phone'] = phone
                        else:
                            # Get city.
                            for city in CITIES:
                                if city.lower() in s.lower():
                                    data['city'] = city
    print("Result: {}".format(data))
    if 'name' in data and 'phone' in data and 'city' in data:
        return data
    return
Beispiel #4
0
def _fetch_details(url):
    """Fetch and parse company's details."""
    print("Connecting to {}".format(url))
    soup = connect(url)
    data = dict()
    # Get company name.
    cont = soup.find(id='result')
    if cont is not None:
        name_tag = cont.find('h2')
        if name_tag is not None:
            data['name'] = cleanstr(cont.find('h2').string)
        table = cont.find('table')
        if table is not None:
            rows = table.find_all('tr')
            if len(rows) > 1:
                row = rows[1]
                for col in row.children:
                    if istag(col):
                        s = str()
                        for el in col.contents:
                            if el.string is not None:
                                if istag(el):
                                    s += cleanstr(el.string)
                                else:
                                    s += cleanstr(el)
                        if 'Tel:' in s:
                            # Get phone number.
                            phone = ''
                            for d in s[5:17]:
                                if d.isdigit():
                                    phone += d
                            if len(phone) == 10:
                                data['phone'] = phone
                        else:
                            # Get city.
                            for city in CITIES:
                                if city.lower() in s.lower():
                                    data['city'] = city
    print("Result: {}".format(data))
    if 'name' in data and 'phone' in data and 'city' in data:
        return data
    return