Exemplo n.º 1
0
def collect_company_survey(stock_info):
    query_id = estimate_market(
        stock_info.stock_number) + stock_info.stock_number

    company_survey_url = company_survey.format(query_id)
    survey_html = send_request(company_survey_url)
    survey_soup = BeautifulSoup(survey_html, 'lxml')
    stock_info.stock_name = survey_soup.find(
        'p', class_='key').find('a').text.strip()
    survey_table = survey_soup.find('table', id='Table0').find_all('td')
    stock_info.company_name_cn = survey_table[0].text.strip()
    stock_info.company_name_en = survey_table[1].text.strip()
    stock_info.account_firm = survey_table[30].text.strip()
    stock_info.law_firm = survey_table[29].text.strip()
    stock_info.industry_involved = survey_table[10].text.strip()
    stock_info.business_scope = survey_table[32].text.strip()
    stock_info.company_introduce = survey_table[31].text.strip()
    stock_info.area = survey_table[23].text.strip()

    core_concept_url = core_concept.format(query_id)
    concept_html = send_request(core_concept_url)
    market_plate = BeautifulSoup(concept_html, 'lxml').find('div', class_='summary').find('p').text\
        .replace(u'要点一:所属板块 ', '').replace(u'。', '').strip()
    stock_info.market_plate = market_plate
    stock_info.update_time = datetime.datetime.now()
    stock_info.save()
Exemplo n.º 2
0
def collect_company_survey(stock_info):
    query_id = estimate_market(
        stock_info.stock_number) + stock_info.stock_number

    company_survey_url = company_survey.format(query_id)
    survey_html = send_request(company_survey_url)
    survey_soup = BeautifulSoup(survey_html, 'lxml')
    if not survey_soup or survey_soup.find('table', id='Table0'):
        return

    survey_table = survey_soup.find('table', id='Table0').find_all('td')
    if not survey_table:
        return

    stock_info.stock_name = survey_table[4].text.strip()
    stock_info.company_name_cn = survey_table[0].text.strip()
    stock_info.company_name_en = survey_table[1].text.strip()
    stock_info.used_name = survey_table[2].text.strip()
    stock_info.account_firm = survey_table[30].text.strip()
    stock_info.law_firm = survey_table[29].text.strip()
    stock_info.industry_involved = survey_table[10].text.strip()
    stock_info.business_scope = survey_table[32].text.strip()
    stock_info.company_introduce = survey_table[31].text.strip()
    stock_info.area = survey_table[23].text.strip()

    core_concept_url = core_concept.format(query_id)
    concept_html = send_request(core_concept_url)
    market_plate = BeautifulSoup(concept_html, 'lxml').find('div', class_='summary').find('p').text\
        .replace(u'要点一:所属板块 ', '').replace(u'。', '').strip()
    stock_info.market_plate = market_plate

    if 'sh' in query_id:
        q_id = stock_info.stock_number + '1'
    elif 'sz' in query_id:
        q_id = stock_info.stock_number + '2'

    if q_id:
        stock_value_url = stock_value.format(q_id)
        try:
            res = send_request(stock_value_url)
            data = json.loads(res.replace('callback(',
                                          '').replace(')', ''))['Value']
            circulated_value = int(data[45])
            total_value = int(data[46])
            stock_info.circulated_value = circulated_value
            stock_info.total_value = total_value
        except Exception, e:
            logging.error('Error when get %s value:%s' %
                          (stock_info.stock_number, e))
def collect_company_survey(stock_info):
    query_id = estimate_market(stock_info.stock_number)+stock_info.stock_number

    company_survey_url = company_survey.format(query_id)
    survey_html = send_request(company_survey_url)
    survey_soup = BeautifulSoup(survey_html, 'lxml')
    survey_table = survey_soup.find('table', id='Table0').find_all('td')
    if not survey_soup or not survey_table:
        return

    stock_info.stock_name = survey_table[4].text.strip()
    stock_info.company_name_cn = survey_table[0].text.strip()
    stock_info.company_name_en = survey_table[1].text.strip()
    stock_info.used_name = survey_table[2].text.strip()
    stock_info.account_firm = survey_table[30].text.strip()
    stock_info.law_firm = survey_table[29].text.strip()
    stock_info.industry_involved = survey_table[10].text.strip()
    stock_info.business_scope = survey_table[32].text.strip()
    stock_info.company_introduce = survey_table[31].text.strip()
    stock_info.area = survey_table[23].text.strip()

    core_concept_url = core_concept.format(query_id)
    concept_html = send_request(core_concept_url)
    market_plate = BeautifulSoup(concept_html, 'lxml').find('div', class_='summary').find('p').text\
        .replace(u'要点一:所属板块 ', '').replace(u'。', '').strip()
    stock_info.market_plate = market_plate

    if 'sh' in query_id:
        q_id = stock_info.stock_number + '1'
    elif 'sz' in query_id:
        q_id = stock_info.stock_number + '2'

    if q_id:
        stock_value_url = stock_value.format(q_id)
        try:
            res = send_request(stock_value_url)
            data = json.loads(res.replace('callback(', '').replace(')', ''))['Value']
            circulated_value = int(data[45])
            total_value = int(data[46])
            stock_info.circulated_value = circulated_value
            stock_info.total_value = total_value
        except Exception, e:
            logging.error('Error when get %s value:%s' % (stock_info.stock_number, e))
def collect_company_survey(stock_info):
    query_id = estimate_market(stock_info.stock_number)+stock_info.stock_number

    company_survey_url = company_survey.format(query_id)
    survey_html = send_request(company_survey_url)
    survey_soup = BeautifulSoup(survey_html, 'lxml')
    survey_table = survey_soup.find('table', id='Table0').find_all('td')
    stock_info.company_name_cn = survey_table[0].text
    stock_info.company_name_en = survey_table[1].text
    stock_info.account_firm = survey_table[30].text
    stock_info.law_firm = survey_table[29].text
    stock_info.industry_involved = survey_table[10].text
    stock_info.business_scope = survey_table[32].text
    stock_info.company_introduce = survey_table[31].text
    stock_info.area = survey_table[23].text

    core_concept_url = core_concept.format(query_id)
    concept_html = send_request(core_concept_url)
    concept_soup = BeautifulSoup(concept_html, 'lxml').find('div', class_='summary').find('p').text
    stock_info.market_plate = concept_soup.replace(u'要点一:所属板块 ', '').replace(u'。', '').split(u',')
    stock_info.update_time = datetime.datetime.now()
    stock_info.save()