Exemple #1
0
def my_task(code, fundCompleted, f):
    if code not in fundCompleted:
        with get_sqlite_conn("fund") as conn:
            table = DBTable(conn, "FundDaily_{}".format(code), FundDailyRec)

            get_net_value(table, code)

            f.write("{}\n".format(code))
Exemple #2
0
import requests

from database.DBTable import DBTable
from database.FundInfoRecord import FundInfo


def get_fund_info(code):
    url = "http://fundf10.eastmoney.com/jjjz_{}.html".format(code)
    html = requests.get(url)
    html.encoding = 'utf-8'
    currentPage = BeautifulSoup(html.text, 'lxml')

    dd = currentPage.find('dd', {'id': 'f10_menu_jjgs'})

    company_url = dd.find('a')['href']

    company_code = basename(company_url)[:-5]

    return company_code


if __name__ == "__main__":
    with get_sqlite_conn("fund") as conn:
        fundInfoTable = DBTable(conn, "FundInfo", FundInfo)
        df = fundInfoTable.getDataFrame(None, ['code'])
        for code in df.code.values:
            company_code = get_fund_info(code)
            fundInfoTable.updateRecords({'company_code': company_code},
                                        "code='{}'".format(code))
            print(code, company_code)