Beispiel #1
0
def selectTender():
    mh = MysqlHelper('120.55.52.30', 'bigdata', 'bigdata', 'lezhu_new', 'utf8')
    start_time = int(time.mktime(datetime.now().date().timetuple()))  # 今天0点
    end_time = start_time - 86400  # 昨天0点
    sql = 'select title,content,addtime,edittime,`from`,address,cattitle from tp_tender where %d <= addtime and addtime < %d ' % (
        end_time, start_time)  #查询了昨天的数据
    tenders = mh.find(sql)
    lmh = MysqlHelper('localhost', 'root', 'ok', 'ultrax', 'utf8')
    select_max_sql = "select MAX(aid) as id from pre_portal_article_title"
    if (len(tenders) > 0):
        for tender in tenders:
            title = tender['title']
            content = tender['content']
            insert_title = "insert into pre_portal_article_title (catid,bid,uid,username,title,highlight,author,`from`,`fromurl`," \
                           "url,summary,pic,thumb," \
                           "remote,id,idtype,contents,allowcomment,owncomment,click1,click2,click3,click4," \
                           "click5,click6,click7,click8,tag,dateline,status,showinnernav,preaid,nextaid,htmlmade,htmlname,htmldir) VALUES " \
                           "('%d','%d','%d','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d','%d','%d','%s','%d','%d','%d','%d','%d','%d','%d'" \
                           ", '%d', '%d', '%d', '%d', '%d',unix_timestamp(now()), '%d', '%d', '%d', '%d', '%d', '%s', '%s')" % \
                           (5, 0, 1, 'admin', title, '|||', '', '', '', '', '', '', 0, 0, 0, '', 1, 1, 0, 0, 0, 0, 0, 0,
                            0, 0, 0, 0, 0, 0, 0, 0, 0, '', '')
            lmh.cud(insert_title)
            max_id = lmh.find(select_max_sql)
            id = int(max_id[0]['id'])
            insert_content = "insert into pre_portal_article_content (aid, id, idtype, title, content, pageorder, dateline" \
                             ") VALUES ('%d','%d','%s','%s','%s','%d',unix_timestamp(now()))" % (
                             id, 0, '', '', content, 5)
            lmh.cud(insert_content)
Beispiel #2
0
def main():
    mh = MysqlHelper('47.110.88.64', 'root', 'admin963', 'zhizhudashi', 'utf8')

    url_list = [1, 342, 1679, 344, 11]
    for i in url_list:
        url = 'http://top.baidu.com/buzz?b=' + str(i) + '&c=513&fr=topbuzz_b42_c513'
        try:
            response = requests.get(url, headers=headers)
            response.encoding = 'gb2312'
            html = response.text
            doc = pq(html)
            new_names = doc(".list-title")
            for name in new_names.items():
                string = name.text()
                select_sql = 'select * from keywords where title = "%s"' % (string)
                id = mh.find_id(select_sql)
                if id != None and id != '' and id != 0:
                    continue
                else:
                    insert_sql = "insert into keywords (title,object_id) values ('%s',%d)" % (string, 1)
                    mh.cud(insert_sql)
            # f = open('百度热词.txt', 'a')
            # for name in new_names.items():
            #     string = name.text()
            #     f.write('\n' + str(string))
            # f.close()
        except Exception as e:
            print(e)
Beispiel #3
0
def insertData():
    mh = MysqlHelper('47.110.88.64', 'root', 'admin963', 'wordpress', 'utf8')
    sql = "select * from tp_knowledge_copy limit 35000,5000"
    knows = mh.find(sql)
    select_max_sql = "select MAX(id) as id from wp_posts"
    for know in knows:
        title = str(know['title'])  # 标题
        print(title)
        post_content = know['contentHtml']
        title_split = str(title)[0:16]
        post_name = quote(title_split, 'utf-8')
        insert = "insert into wp_posts (post_author,post_date,post_date_gmt,post_content," \
                 "post_title,post_excerpt,post_status,comment_status, " \
                 "ping_status, post_password, post_name, to_ping, pinged, post_modified, " \
                 "post_modified_gmt,post_content_filtered, post_parent, " \
                 "guid, menu_order, post_type, post_mime_type, comment_count) VALUES " \
                 "('%d',now(),now(),'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s'," \
                 "now(),now(),'%s','%s','%s','%s','%s','%s','%d')" % \
                 (
                     1, post_content, title, '', 'publish', 'open', 'open', '', post_name, '', '', '', 0, '', 0, 'post',
                     '',
                     0)
        mh.cud(insert)
        max_id = mh.find(select_max_sql)
        id = int(max_id[0]['id'])
        insert_term = "insert into wp_term_relationships (object_id, term_taxonomy_id) VALUES ('%d','%d')" % (
            id, 7)
        mh.cud(insert_term)
Beispiel #4
0
def insertData():
    mh = MysqlHelper('47.110.88.64', 'root', 'admin963', 'wordpress', 'utf8')
    sql = 'select * from top_good_zaojiatongxinxijia limit 1000'
    cost_msg = mh.find(sql)
    select_max_sql = "select MAX(id) as id from wp_posts"
    if len(cost_msg) > 0:
        for cost in cost_msg:
            title = cost['title']  # 商品名
            title_split = str(title)[0:16]
            post_name = quote(title_split, 'utf-8')
            source = cost['company']  # 城市/省
            industry = cost['industry']  # 行业
            unit = cost['unit']  # 单位
            date = cost['infomIssueDate']  # 发布日期
            timeArray = int(time.mktime(time.strptime(date, '%Y-%m-%d')))
            notax_avg = cost['notaxAvg']  # 除税平均价
            notax_price = cost['notaxInformation']  # 除税价
            notax_min = cost['notaxMin']  # 除税最小值
            notax_max = cost['notaxMax']  # 除税最大值
            notax_upprice = cost['notaxUpprice']  # 除税上期价格
            spec = cost['specificationType']  # 商品类型
            tax_avg = cost['taxAvg']
            if tax_avg == '':
                tax_avg = '--'  # 含税平均价
            tax_information = cost['taxInformation']
            if tax_information == "无":
                tax_information = '--'  # 含税价
            tax_max = cost['taxMax']  # 含税最大值
            tax_min = cost['taxMin']  # 含税最小值
            tax_upprice = cost['taxUpprice']  # 含税上期价格
            main_title = title + "&nbsp;&nbsp;&nbsp;" + spec + "&nbsp;&nbsp;&nbsp;" + source
            post_content = '<p><table border="1" cellspacing="0" style="width:100%;text-align:center;height:25%"><tr>' + source + '</tr> <tr><td>名称</td><td>行业</td><td>规格型号</td><td>单位</td><td>更新时间</td></tr><tr><td>' + title + '</td><td>' + industry + '</td><td>' + spec + '</td><td>' + unit + '</td><td>' + date + '</td></tr></table><table border="1" cellspacing="0" style="width:100%;text-align:center;height:25%"><tr>含税信息价</tr><tr><td>当前价格</td><td>上期价格</td><td>平均价格</td><td>最高价格</td><td>最低价格</td></tr><tr><td>' + str(
                tax_information) + '</td><td>' + str(tax_upprice) + '</td><td>' + str(tax_avg) + '</td><td>' + str(
                tax_max) + '</td><td>' + str(
                tax_min) + '</td></tr></table><table border="1" cellspacing="0" style="width:100%;text-align:center;height:25%"><tr>除税信息价</tr><tr><td>当前价格</td><td>上期价格</td><td>平均价格</td><td>最高价格</td><td>最低价格</td></tr><tr><td>' + str(
                notax_price) + '</td><td>' + str(notax_upprice) + '</td><td>' + str(notax_avg) + '</td><td>' + str(
                notax_max) + '</td><td>' + str(notax_min) + '</td></tr></table></table></p>'
            '''
            pre_content = '<p>' + source + '</p><p>名称:' + title + '</p>' + \
                          '<p>行业:' + industry + '</p><p>规格型号:' + spec + '<p>单位:' + unit + '</p>' + '<p>更新时间:' + \
                          date + '</p>' + \
                          '<p>含税信息价</p>' + '<p>当前价格:' + tax_information + '</p>' + '<p>上期价格:' + tax_upprice + '</p>' + \
                          '<p>平均价格:' + tax_avg + '</p><p>最高价格:' + tax_max + '</p><p>最低价格:' + tax_min + '</p>' + \
                          '<p>除税信息价</p>' + '<p>当前价格:' + notax_price + '</p>' + '<p>上期价格:' + notax_upprice + '</p>' + \
                          '<p>平均价格:' + notax_avg + '</p><p>最高价格:' + notax_max + '</p><p>最低价格:' + notax_min + '</p>'
            '''
            insert = "insert into wp_posts (post_author,post_date,post_date_gmt,post_content,post_title,post_excerpt,post_status,comment_status, " \
                     "ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,post_content_filtered, post_parent, " \
                     "guid, menu_order, post_type, post_mime_type, comment_count) VALUES " \
                     "('%d',now(),now(),'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s',now(),now(),'%s','%s','%s','%s','%s','%s','%d')" % \
                     (
                         1, post_content, main_title, '', 'publish', 'open', 'open', '', post_name, '', '', '', 0, '', 0,
                         'post',
                         '',
                         0)
            mh.cud(insert)
            max_id = mh.find(select_max_sql)
            id = int(max_id[0]['id'])
            insert_term = "insert into wp_term_relationships (object_id, term_taxonomy_id) VALUES ('%d','%d')" % (id, 10)
            mh.cud(insert_term)
Beispiel #5
0
def insertData():
    mh = MysqlHelper('47.110.88.64', 'root', 'admin963', 'wordpress', 'utf8')
    sql = "select * from tp_goods_copy limit 35000,5000"
    goods = mh.find(sql)
    select_max_sql = "select MAX(id) as id from wp_posts"
    for good in goods:
        title = str(good['title'])
        post_content = '<p>' + title + '</p>' + '<p>单位:' + good['unit'] + '</p>' + '<p>价钱:' + str(
            good['price']) + '</p>' \
                       + '<p>公司名称:' + good['shoptitle'] + '</p>' + '<p>联系方式:' \
                       + str(good['usermobile']) + '</p>'
        title_split = str(title)[0:16]
        post_name = quote(title_split, 'utf-8')
        print(title_split)
        # pics = good['pics']
        # pic_list = pics.split(',')
        # if len(pic_list) > 0:
        #     for pic in pic_list:
        #         post_content = post_content+'<figure class="wp-block-image"><img src="'+pic+'"alt=""/></figure>'
        # print(post_content)
        insert = "insert into wp_posts (post_author,post_date,post_date_gmt,post_content,post_title,post_excerpt,post_status,comment_status, " \
                 "ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,post_content_filtered, post_parent, " \
                 "guid, menu_order, post_type, post_mime_type, comment_count) VALUES " \
                 "('%d',now(),now(),'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s',now(),now(),'%s','%s','%s','%s','%s','%s','%d')" % \
                 (
                     1, post_content, title, '', 'publish', 'open', 'open', '', post_name, '', '', '', 0, '', 0, 'post',
                     '',
                     0)
        mh.cud(insert)
        max_id = mh.find(select_max_sql)
        id = int(max_id[0]['id'])
        insert_term = "insert into wp_term_relationships (object_id, term_taxonomy_id) VALUES ('%d','%d')" % (
            id, 6)
        mh.cud(insert_term)
Beispiel #6
0
def insertData():
    mh = MysqlHelper('localhost', 'root', 'ok', 'ultrax', 'utf8')
    sql = "select * from tp_goods limit 100"  #设置了条数
    goods = mh.find(sql)
    select_max_sql = "select MAX(aid) as id from pre_portal_article_title"
    for good in goods:
        title = str(good['title'])
        post_content =  '<p>单位:' + good['unit'] + '</p>' + '<p>价钱:' + str(
            good['price']) + '</p>' \
                       + '<p>公司名称:' + good['shoptitle'] + '</p>' + '<p>联系方式:' \
                       + str(good['usermobile']) + '</p>' + \
                       '<p>商品详情:' + str(good['content']) + '</p>'
        pics = good['pics']
        pic_list = pics.split(',')
        if len(pic_list) > 0:
            for pic in pic_list:
                post_content = post_content + '<img class="" src="' + pic + '"alt="" data-original="' + pic + '"/> '
        print(post_content)
        insert_title = "insert into pre_portal_article_title (catid,bid,uid,username,title,highlight,author,`from`,`fromurl`," \
                       "url,summary,pic,thumb," \
                       "remote,id,idtype,contents,allowcomment,owncomment,click1,click2,click3,click4," \
                       "click5,click6,click7,click8,tag,dateline,status,showinnernav,preaid,nextaid,htmlmade,htmlname,htmldir) VALUES " \
                       "('%d','%d','%d','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d','%d','%d','%s','%d','%d','%d','%d','%d','%d','%d'" \
                       ", '%d', '%d', '%d', '%d', '%d',unix_timestamp(now()), '%d', '%d', '%d', '%d', '%d', '%s', '%s')" % \
                       (3, 0, 1, 'admin', title, '|||', '', '', '', '', '', '', 0, 0, 0, '', 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, '', '')
        mh.cud(insert_title)
        max_id = mh.find(select_max_sql)
        id = int(max_id[0]['id'])
        insert_content = "insert into pre_portal_article_content (aid, id, idtype, title, content, pageorder, dateline" \
                         ") VALUES ('%d','%d','%s','%s','%s','%d',unix_timestamp(now()))" % (id, 0, '', title, post_content, 1)
        mh.cud(insert_content)
Beispiel #7
0
def insertData():
    mh = MysqlHelper('localhost', 'root', 'ok', 'ultrax', 'utf8')
    sql = 'select * from top_good_zaojiatongcankaojia'
    cost_msg = mh.find(sql)
    select_max_sql = "select MAX(aid) as id from pre_portal_article_title"
    if len(cost_msg) > 0:
        for cost in cost_msg:
            title = cost['materialRef_name']  # 标题名称
            first_title = cost['title']
            city = cost['region']  # 城市/省
            unit = cost['unit']  # 单位
            date = cost['updatetime']  # 发布日期
            timeArray = int(time.mktime(time.strptime(str(date).split(" ")[0], '%Y-%m-%d')))
            avg = cost['avg']  # 均价
            price_min = cost['min']  # 最小值
            price_max = cost['max']  # 最大值
            upanddown = cost['upanddown']  # 涨跌价
            source = cost['source']  # 来源
            spec = cost['specificationType']  # 商品类型
            main_title = title + "&nbsp;&nbsp;&nbsp;" + spec + "&nbsp;&nbsp;&nbsp;" + source
            pre_content = '<p><table border="1" cellspacing="0" style="width:100%;text-align:center;height:20%"><tr>' + first_title + \
                          '</tr> <tr><td>产品名称</td><td>规格型号</td><td>单位</td><td>更新时间</td><td>城市</td><td>来源</td></tr><tr><td>' + title + '</td><td>' + spec + '</td><td>' + unit + '</td><td>' + date + '</td><td>' + city + '</td><td>'+source+'</td></tr></table><table border="1" cellspacing="0" style="width:100%;text-align:center;height:20%"><tr style="width:100%;text-align:center;height:15%">参考价(单位:元)</tr><tr><td>最小价格</td><td>最大价格</td><td>平均价格</td><td>涨跌价格</td></tr><tr><td>' + str(
                price_min) + '</td><td>' + str(price_max) + '</td><td>' + str(avg) + '</td><td>' + str(
                upanddown) + '</td>'
            '''
            pre_content = '<p>' + source + '</p><p>名称:' + title + '</p>' + \
                          '<p>行业:' + industry + '</p><p>规格型号:' + spec + '<p>单位:' + unit + '</p>' + '<p>更新时间:' + \
                          date + '</p>' + \
                          '<p>含税信息价</p>' + '<p>当前价格:' + tax_information + '</p>' + '<p>上期价格:' + tax_upprice + '</p>' + \
                          '<p>平均价格:' + tax_avg + '</p><p>最高价格:' + tax_max + '</p><p>最低价格:' + tax_min + '</p>' + \
                          '<p>除税信息价</p>' + '<p>当前价格:' + notax_price + '</p>' + '<p>上期价格:' + notax_upprice + '</p>' + \
                          '<p>平均价格:' + notax_avg + '</p><p>最高价格:' + notax_max + '</p><p>最低价格:' + notax_min + '</p>'
            '''
            insert_title = "insert into pre_portal_article_title (catid,bid,uid,username,title,highlight,author,`from`,`fromurl`," \
                           "url,summary,pic,thumb," \
                           "remote,id,idtype,contents,allowcomment,owncomment,click1,click2,click3,click4," \
                           "click5,click6,click7,click8,tag,dateline,status,showinnernav,preaid,nextaid,htmlmade,htmlname,htmldir) VALUES " \
                           "('%d','%d','%d','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d','%d','%d','%s','%d','%d','%d','%d','%d','%d','%d'" \
                           ", '%d', '%d', '%d', '%d', '%d','%d', '%d', '%d', '%d', '%d', '%d', '%s', '%s')" % \
                           (10, 0, 1, 'admin', main_title, '|||', '', '', '', '', '', '', 0, 0, 0, '', 1, 1, 0, 0, 0, 0,
                            0, 0, 0, 0, 0, 0, timeArray, 0, 0, 0, 0, 0, '', '')
            mh.cud(insert_title)
            max_id = mh.find(select_max_sql)
            id = int(max_id[0]['id'])
            insert_content = "insert into pre_portal_article_content (aid, id, idtype, title, content, pageorder, dateline" \
                             ") VALUES ('%d','%d','%s','%s','%s','%d','%d')" % (
                                 id, 0, '', '', pre_content.strip(), 1, timeArray)
            mh.cud(insert_content)
Beispiel #8
0
def insertData():
    mh = MysqlHelper('47.110.88.64', 'root', 'admin963', 'wordpress', 'utf8')
    sql = 'select * from tp_job_recruit'
    recruits = mh.find(sql)
    select_max_sql = "select MAX(id) as id from wp_posts"
    if len(recruits) > 0:
        for recruit in recruits:
            address = recruit['workplace']
            title = recruit['title'] + "  " + address
            title_split = str(title)[0:17]
            print(title_split)
            post_name = quote(title_split, 'utf-8')
            experience = recruit['experience']
            content = recruit['description']
            company = recruit['company']  # 公司
            if company == '':
                company = '无'
            tel = recruit['telephone']
            position = recruit['positiontitle']  # 分类
            price = recruit['salary']  # 薪金
            release_time = recruit['addtime']
            timeArray = time.localtime(release_time)
            otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
            post_content = '<p>岗位:' + title + ' ( ' + position + ' ) ' '</p> ' + '<p>发布时间:' + otherStyleTime + '</p>' + \
                           '<p>电话:' + tel + '</p>' + '<p>公司:' + company + '</p>' + \
                           '<p>工作经验:' + experience + \
                           '<p>薪资:' + price + '</p>' + '<p>详情:' + content + '</p>' + \
                           '<p>地址:' + address
            insert = "insert into wp_posts (post_author,post_date,post_date_gmt,post_content," \
                     "post_title,post_excerpt,post_status,comment_status, " \
                     "ping_status, post_password, post_name, to_ping, pinged, post_modified," \
                     " post_modified_gmt,post_content_filtered, post_parent, " \
                     "guid, menu_order, post_type, post_mime_type, comment_count) VALUES " \
                     "('%d',now(),now(),'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s'," \
                     "now(),now(),'%s','%s','%s','%s','%s','%s','%d')" % \
                     (
                         1, post_content, title, '', 'publish', 'open', 'open', '', post_name, '', '', '', 0, '', 0,
                         'post', '',
                         0)
            mh.cud(insert)
            max_id = mh.find(select_max_sql)
            id = int(max_id[0]['id'])
            insert_term = "insert into wp_term_relationships (object_id, term_taxonomy_id) VALUES ('%d','%d')" % (
                id, 4)
            mh.cud(insert_term)
def insertData():
    mh = MysqlHelper('47.110.88.64', 'root', 'admin963', 'wordpress', 'utf8')
    sql = 'select * from tp_equipment limit 1000'
    equiments = mh.find(sql)
    select_max_sql = "select MAX(id) as id from wp_posts"
    if len(equiments) > 0:
        for equiment in equiments:
            title = equiment['title']
            title_split = str(title)[0:17]
            post_name = quote(title_split, 'utf-8')
            address = equiment['address']
            pic = equiment['pic']
            content = equiment['content']
            tel = equiment['telephone']
            contact = equiment['contact']
            brand = equiment['brandtitle']  # 品牌
            type = equiment['typetitle']  # 型号
            price = equiment['rentpricelist']  # 价格
            if price == '':
                price = '面议'
            post_content = '<p>品牌:' + brand + '</p> ' + '<p>型号:' + type + '</p>' + \
                      '<p>电话:' + tel + '</p>' + '<p>联系人:' + contact + '</p>' + \
                      '<p>价格:' + price + '</p>' + '<p>详情:' + str(content).split("\n")[0] + '</p>' + \
                      '<p>地址:' + address + '</p>'


            insert = "insert into wp_posts (post_author,post_date,post_date_gmt,post_content,post_title,post_excerpt,post_status,comment_status, " \
                     "ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,post_content_filtered, post_parent, " \
                     "guid, menu_order, post_type, post_mime_type, comment_count) VALUES " \
                     "('%d',now(),now(),'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s',now(),now(),'%s','%s','%s','%s','%s','%s','%d')" % \
                     (
                         1, post_content, title, '', 'publish', 'open', 'open', '', post_name, '', '', '', 0, '', 0,
                         'post',
                         '',
                         0)
            mh.cud(insert)
            max_id = mh.find(select_max_sql)
            id = int(max_id[0]['id'])
            insert_term = "insert into wp_term_relationships (object_id, term_taxonomy_id) VALUES ('%d','%d')" % (
                id, 9)
            mh.cud(insert_term)
Beispiel #10
0
def insertData():
    mh = MysqlHelper('localhost', 'root', 'ok', 'ultrax', 'utf8')
    sql = 'select * from tp_job_recruit limit 100'
    recruits = mh.find(sql)
    select_max_sql = "select MAX(aid) as id from pre_portal_article_title"
    if len(recruits) > 0:
        for recruit in recruits:
            title = recruit['title']
            address = recruit['workplace']
            experience = recruit['experience']
            content = recruit['description']
            company = recruit['company']  # 公司
            if company == '':
                company = '无'
            tel = recruit['telephone']
            position = recruit['positiontitle']  # 分类
            price = recruit['salary']  # 薪金
            release_time = recruit['addtime']
            timeArray = time.localtime(release_time)
            otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
            pre_content = '<p>岗位:' + title + ' ( ' + position + ' ) ' '</p> ' + '<p>发布时间:' + otherStyleTime + '</p>' + \
                          '<p>电话:' + tel + '</p>' + '<p>公司:' + company + '</p>' + \
                          '<p>工作经验:' + experience + \
                          '<p>薪资:' + price + '</p>' + '<p>详情:' + content + '</p>' + \
                          '<p>地址:' + address
            insert_title = "insert into pre_portal_article_title (catid,bid,uid,username,title,highlight,author,`from`,`fromurl`," \
                           "url,summary,pic,thumb," \
                           "remote,id,idtype,contents,allowcomment,owncomment,click1,click2,click3,click4," \
                           "click5,click6,click7,click8,tag,dateline,status,showinnernav,preaid,nextaid,htmlmade,htmlname,htmldir) VALUES " \
                           "('%d','%d','%d','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d','%d','%d','%s','%d','%d','%d','%d','%d','%d','%d'" \
                           ", '%d', '%d', '%d', '%d', '%d','%d', '%d', '%d', '%d', '%d', '%d', '%s', '%s')" % \
                           (8, 0, 1, 'admin', title, '|||', '', '', '', '', '', '', 0, 0, 0, '', 1, 1, 0, 0, 0, 0, 0, 0,
                            0, 0, 0, 0, release_time, 0, 0, 0, 0, 0, '', '')
            mh.cud(insert_title)
            max_id = mh.find(select_max_sql)
            id = int(max_id[0]['id'])
            insert_content = "insert into pre_portal_article_content (aid, id, idtype, title, content, pageorder, dateline" \
                             ") VALUES ('%d','%d','%s','%s','%s','%d','%d')" % (
                                 id, 0, '', '', pre_content, 1, release_time)
            mh.cud(insert_content)
def insertData():
    mh = MysqlHelper('47.110.88.64', 'root', 'admin963', 'wordpress', 'utf8')
    sql = 'select * from top_good_zaojiatongcankaojia'
    cost_msg = mh.find(sql)
    select_max_sql = "select MAX(id) as id from wp_posts"
    if len(cost_msg) > 0:
        for cost in cost_msg:
            date = cost['updatetime']  # 发布日期
            title = cost['materialRef_name'] # 标题名称
            post_name = quote(title, 'tuf-8')
            first_title = cost['title']
            city = cost['region']  # 城市/省
            unit = cost['unit']  # 单位
            timeArray = int(time.mktime(time.strptime(str(date).split(" ")[0], '%Y-%m-%d')))
            avg = cost['avg']  # 均价
            price_min = cost['min']  # 最小值
            price_max = cost['max']  # 最大值
            upanddown = cost['upanddown']  # 涨跌价
            source = cost['source']  # 来源
            spec = cost['specificationType']  # 商品类型
            main_title = title + "&nbsp;&nbsp;&nbsp;" + spec + "&nbsp;&nbsp;&nbsp;" + source + "&nbsp;&nbsp;&nbsp;" + city
            post_content = '<p><table border="1" cellspacing="0" style="width:100%;text-align:center;height:20%"><tr>' + first_title + \
                           '</tr> <tr><td>产品名称</td><td>规格型号</td><td>单位</td><td>更新时间</td><td>城市</td><td>来源</td></tr><tr><td>' + title + '</td><td>' + spec + '</td><td>' + unit + '</td><td>' + date + '</td><td>' + city + '</td><td>' + source + '</td></tr></table><table border="1" cellspacing="0" style="width:100%;text-align:center;height:20%"><tr style="width:100%;text-align:center;height:15%">参考价(单位:元)</tr><tr><td>最小价格</td><td>最大价格</td><td>平均价格</td><td>涨跌价格</td></tr><tr><td>' + str(
                price_min) + '</td><td>' + str(price_max) + '</td><td>' + str(avg) + '</td><td>' + str(
                upanddown) + '</td>'
            insert = "insert into wp_posts (post_author,post_date,post_date_gmt,post_content,post_title,post_excerpt,post_status,comment_status, " \
                     "ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,post_content_filtered, post_parent, " \
                     "guid, menu_order, post_type, post_mime_type, comment_count) VALUES " \
                     "('%d',now(),now(),'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s',now(),now(),'%s','%s','%s','%s','%s','%s','%d')" % \
                     (
                         1, post_content, main_title, '', 'publish', 'open', 'open', '', post_name, '', '', '', 0, '', 0,
                         'post',
                         '',
                         0)
            mh.cud(insert)
            max_id = mh.find(select_max_sql)
            id = int(max_id[0]['id'])
            insert_term = "insert into wp_term_relationships (object_id, term_taxonomy_id) VALUES ('%d','%d')" % (id, 10)
            mh.cud(insert_term)
Beispiel #12
0
def insertData():
    mh = MysqlHelper('localhost', 'root', 'ok', 'ultrax', 'utf8')
    sql = 'select * from tp_equipment limit 100'
    equiments = mh.find(sql)
    select_max_sql = "select MAX(aid) as id from pre_portal_article_title"
    if len(equiments) > 0:
        for equiment in equiments:
            title = equiment['title']
            address = equiment['address']
            pic = equiment['pic']
            content = equiment['content']
            tel = equiment['telephone']
            contact = equiment['contact']
            brand = equiment['brandtitle']  # 品牌
            type = equiment['typetitle']  # 型号
            price = equiment['rentpricelist']  # 价格
            if price == '':
                price = '面议'
            pre_content = '<p>品牌:' + brand + '</p> ' + '<p>型号:' + type + '</p>' + \
                          '<p>电话:' + tel + '</p>' + '<p>联系人:' + contact + '</p>' + \
                          '<p>价格:' + price + '</p>' + '<p>详情:' + content + '</p>' + \
                          '<p>地址:' + address + '</p>' + '<img class="" src=" ' + pic + '"alt="" data-original="' + pic + '"/> '
            insert_title = "insert into pre_portal_article_title (catid,bid,uid,username,title,highlight,author,`from`,`fromurl`," \
                           "url,summary,pic,thumb," \
                           "remote,id,idtype,contents,allowcomment,owncomment,click1,click2,click3,click4," \
                           "click5,click6,click7,click8,tag,dateline,status,showinnernav,preaid,nextaid,htmlmade,htmlname,htmldir) VALUES " \
                           "('%d','%d','%d','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d','%d','%d','%s','%d','%d','%d','%d','%d','%d','%d'" \
                           ", '%d', '%d', '%d', '%d', '%d',unix_timestamp(now()), '%d', '%d', '%d', '%d', '%d', '%s', '%s')" % \
                           (4, 0, 1, 'admin', title, '|||', '', '', '', '', '', '', 0, 0, 0, '', 1, 1, 0, 0, 0, 0, 0, 0,
                            0, 0, 0, 0, 0, 0, 0, 0, 0, '', '')
            mh.cud(insert_title)
            max_id = mh.find(select_max_sql)
            id = int(max_id[0]['id'])
            insert_content = "insert into pre_portal_article_content (aid, id, idtype, title, content, pageorder, dateline" \
                             ") VALUES ('%d','%d','%s','%s','%s','%d',unix_timestamp(now()))" % (
                                 id, 0, '', '', pre_content, 1)
            mh.cud(insert_content)
Beispiel #13
0
def insertData():
    mh = MysqlHelper('localhost', 'root', 'ok', 'ultrax', 'utf8')
    sql = 'select * from top_good_zaojiatongxinxijia limit 100'
    cost_msg = mh.find(sql)
    select_max_sql = "select MAX(aid) as id from pre_portal_article_title"
    if len(cost_msg) > 0:
        for cost in cost_msg:
            title = cost['title']  # 商品名
            source = cost['company']  # 城市/省
            industry = cost['industry']  # 行业
            unit = cost['unit']  # 单位
            date = cost['infomIssueDate']  # 发布日期
            timeArray = int(time.mktime(time.strptime(date, '%Y-%m-%d')))
            notax_avg = cost['notaxAvg']  # 除税平均价
            notax_price = cost['notaxInformation']  # 除税价
            notax_min = cost['notaxMin']  # 除税最小值
            notax_max = cost['notaxMax']  # 除税最大值
            notax_upprice = cost['notaxUpprice']  # 除税上期价格
            spec = cost['specificationType']  # 商品类型
            tax_avg = cost['taxAvg']
            if tax_avg == '':
                tax_avg = '--'  # 含税平均价
            tax_information = cost['taxInformation']
            if tax_information == "无":
                tax_information = '--'  # 含税价
            tax_max = cost['taxMax']  # 含税最大值
            tax_min = cost['taxMin']  # 含税最小值
            tax_upprice = cost['taxUpprice']  # 含税上期价格
            main_title = title + "&nbsp;&nbsp;&nbsp;" + spec + "&nbsp;&nbsp;&nbsp;" + source
            pre_content = '<p><table border="1" cellspacing="0" style="width:100%;text-align:center;height:25%"><tr>' + source + '</tr> <tr><td>名称</td><td>行业</td><td>规格型号</td><td>单位</td><td>更新时间</td></tr><tr><td>' + title + '</td><td>' + industry + '</td><td>' + spec + '</td><td>' + unit + '</td><td>' + date + '</td></tr></table><table border="1" cellspacing="0" style="width:100%;text-align:center;height:25%"><tr>含税信息价</tr><tr><td>当前价格</td><td>上期价格</td><td>平均价格</td><td>最高价格</td><td>最低价格</td></tr><tr><td>' + str(
                tax_information
            ) + '</td><td>' + str(tax_upprice) + '</td><td>' + str(
                tax_avg
            ) + '</td><td>' + str(tax_max) + '</td><td>' + str(
                tax_min
            ) + '</td></tr></table><table border="1" cellspacing="0" style="width:100%;text-align:center;height:25%"><tr>除税信息价</tr><tr><td>当前价格</td><td>上期价格</td><td>平均价格</td><td>最高价格</td><td>最低价格</td></tr><tr><td>' + str(
                notax_price
            ) + '</td><td>' + str(notax_upprice) + '</td><td>' + str(
                notax_avg) + '</td><td>' + str(notax_max) + '</td><td>' + str(
                    notax_min) + '</td></tr></table></table></p>'
            '''
            pre_content = '<p>' + source + '</p><p>名称:' + title + '</p>' + \
                          '<p>行业:' + industry + '</p><p>规格型号:' + spec + '<p>单位:' + unit + '</p>' + '<p>更新时间:' + \
                          date + '</p>' + \
                          '<p>含税信息价</p>' + '<p>当前价格:' + tax_information + '</p>' + '<p>上期价格:' + tax_upprice + '</p>' + \
                          '<p>平均价格:' + tax_avg + '</p><p>最高价格:' + tax_max + '</p><p>最低价格:' + tax_min + '</p>' + \
                          '<p>除税信息价</p>' + '<p>当前价格:' + notax_price + '</p>' + '<p>上期价格:' + notax_upprice + '</p>' + \
                          '<p>平均价格:' + notax_avg + '</p><p>最高价格:' + notax_max + '</p><p>最低价格:' + notax_min + '</p>'
            '''
            insert_title = "insert into pre_portal_article_title (catid,bid,uid,username,title,highlight,author,`from`,`fromurl`," \
                           "url,summary,pic,thumb," \
                           "remote,id,idtype,contents,allowcomment,owncomment,click1,click2,click3,click4," \
                           "click5,click6,click7,click8,tag,dateline,status,showinnernav,preaid,nextaid,htmlmade,htmlname,htmldir) VALUES " \
                           "('%d','%d','%d','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d','%d','%d','%s','%d','%d','%d','%d','%d','%d','%d'" \
                           ", '%d', '%d', '%d', '%d', '%d','%d', '%d', '%d', '%d', '%d', '%d', '%s', '%s')" % \
                           (11, 0, 1, 'admin', main_title, '|||', '', '', '', '', '', '', 0, 0, 0, '', 1, 1, 0, 0, 0, 0,
                            0, 0, 0, 0, 0, 0, timeArray, 0, 0, 0, 0, 0, '', '')
            mh.cud(insert_title)
            max_id = mh.find(select_max_sql)
            id = int(max_id[0]['id'])
            insert_content = "insert into pre_portal_article_content (aid, id, idtype, title, content, pageorder, dateline" \
                             ") VALUES ('%d','%d','%s','%s','%s','%d','%d')" % (
                                 id, 0, '', '', pre_content.strip(), 1, timeArray)
            mh.cud(insert_content)
Beispiel #14
0
def insertData():
    mh = MysqlHelper('47.110.88.64', 'root', 'admin963', 'wordpress', 'utf8')
    sql = 'select * from top_good_zaojiatongshichangjia limit 1000'
    cost_msg = mh.find(sql)
    select_max_sql = "select MAX(id) as id from wp_posts"
    if len(cost_msg) > 0:
        for cost in cost_msg:
            title = cost['title']  # 商品名
            post_name = quote(title, 'utf-8')
            brand = cost['brand']  # 品牌
            if brand == "":
                brand = '--'
            city = cost['city']  # =城市
            unit = cost['unit']  # 单位
            company = cost['supplier']  # 公司
            date = cost['updatetime']  # 日期
            timeArray = int(time.mktime(time.strptime(date, '%Y-%m')))
            fac_tax_pre = cost['facTaxPrevious']  # 市场价(含税) 上月
            fac_tax_avg = cost['facTaxAverage']  # 市场价(含税) 平均
            fac_tax_hight = cost['facTaxHighest']  # 市场价(含税) 最大值
            fac_tax_low = cost['facTaxLowest']  # 市场价(含税) 最小值
            current_tax_fac = cost['currentPriceFacTax']  # 市场价(含税)

            fac_pre = cost['facPrevious']  # 市场价(除税) 上月
            fac_avg = cost['facAverage']  # 市场价(除税) 平均
            fac_hight = cost['facHighest']  # 市场价(除税) 最大值
            fac_low = cost['facLowest']  # 市场价(除税) 最小值
            current_fac = cost['currentPriceFac']  # 市场价(除税)

            ref_tax_pre = cost['refTaxPrevious']  # 建议价(含税) 上月
            ref_tax_avg = cost['refTaxAverage']  # 建议价(含税) 平均
            ref_tax_hight = cost['refTaxHighest']  # 建议价(含税) 最大值
            ref_tax_low = cost['refTaxLowest']  # 建议价(含税) 最小值
            current_tax_ref = cost['currentPriceRefTax']  # 建议价(含税)

            ref_pre = cost['refPrevious']  # 建议价(除税) 上月
            ref_avg = cost['refAverage']  # 建议价(除税) 平均
            ref_hight = cost['refHighest']  # 建议价(除税) 最大值
            ref_low = cost['refLowest']  # 建议价(除税) 最小值
            current_ref = cost['currentPriceRef']  # 建议价(除税)

            spec = cost['spec']  # 商品类型
            rate = cost['taxRate']  # 税率

            main_title = title + "&nbsp;&nbsp;&nbsp;" + spec + "&nbsp;&nbsp;&nbsp;" + date + "&nbsp;&nbsp;&nbsp;" + city
            post_content = '<p><table border="1" cellspacing="0" style="width:100%;text-align:center;"><tr>供应商:' + company + '</tr> <tr><td>名称</td><td>规格型号</td><td>品牌</td><td>单位</td><td>城市</td><td>更新时间</td></tr><tr><td>' + title + '</td><td>' + spec + '</td><td>' + brand + '</td><td>' + unit + '</td><td>' + city + '</td><td>' + date + '</td></tr></table><table border="1" cellspacing="0" style="width:100%;text-align:center;"><tr>市场价(含税)</tr><tr><td>当前价格</td><td>上月价格</td><td>平均价格</td><td>最高价格</td><td>最低价格</td><td>税率</td></tr><tr><td>' + str(
                current_tax_fac) + '</td><td>' + str(fac_tax_pre) + '</td><td>' + str(fac_tax_avg) + '</td><td>' + str(
                fac_tax_hight) + '</td><td>' + str(
                fac_tax_low) + '</td><td>'+rate+'</td></tr></table><table border="1" cellspacing="0" style="width:100%;text-align:center;"><tr>市场价(除税)</tr><tr><td>当前价格</td><td>上月价格</td><td>平均价格</td><td>最高价格</td><td>最低价格</td><td>税率</td></tr><tr><td>' + str(
                current_fac) + '</td><td>' + str(fac_pre) + '</td><td>' + str(fac_avg) + '</td><td>' + str(
                fac_hight) + '</td><td>' + str(fac_low) + '</td><td>'+rate+'</td></tr></table>' \
                                                          '<table border="1" cellspacing="0" style="width:100%;text-align:center;"><tr>建议价(含税)</tr><tr><td>当前价格</td><td>上月价格</td><td>平均价格</td><td>最高价格</td><td>最低价格</td><td>税率</td></tr><tr><td>' + str(
                current_tax_ref) + '</td><td>' + str(ref_tax_pre) + '</td><td>' + str(ref_tax_avg) + '</td><td>' + str(
                ref_tax_hight) + '</td><td>' + str(ref_tax_low) + '</td><td>'+rate+'</td></tr></table>' \
                                                                  '<table border="1" cellspacing="0" style="width:100%;text-align:center;"><tr>建议价(除税)</tr><tr><td>当前价格</td><td>上月价格</td><td>平均价格</td><td>最高价格</td><td>最低价格</td><td>税率</td></tr><tr><td>' + str(
                current_ref) + '</td><td>' + str(ref_pre) + '</td><td>' + str(ref_avg) + '</td><td>' + str(
                ref_hight) + '</td><td>' + str(ref_low) + '</td><td>'+rate+'</td></tr></table></table></p>'

            insert = "insert into wp_posts (post_author,post_date,post_date_gmt,post_content,post_title,post_excerpt,post_status,comment_status, " \
                     "ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,post_content_filtered, post_parent, " \
                     "guid, menu_order, post_type, post_mime_type, comment_count) VALUES " \
                     "('%d',now(),now(),'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s',now(),now(),'%s','%s','%s','%s','%s','%s','%d')" % \
                     (
                         1, post_content, main_title, '', 'publish', 'open', 'open', '', post_name, '', '', '', 0, '', 0,
                         'post',
                         '',
                         0)
            mh.cud(insert)
            max_id = mh.find(select_max_sql)
            id = int(max_id[0]['id'])
            insert_term = "insert into wp_term_relationships (object_id, term_taxonomy_id) VALUES ('%d','%d')" % (
                id, 10)
            mh.cud(insert_term)
Beispiel #15
0
def insertData():
    mh = MysqlHelper('localhost', 'root', 'ok', 'ultrax', 'utf8')
    sql = 'select * from top_good_zaojiatongshichangjia limit 100'
    cost_msg = mh.find(sql)
    select_max_sql = "select MAX(aid) as id from pre_portal_article_title"
    if len(cost_msg) > 0:
        for cost in cost_msg:
            title = cost['title']  # 商品名
            brand = cost['brand']  # 品牌
            if brand == "":
                brand = '--'
            city = cost['city']  # =城市
            unit = cost['unit']  # 单位
            company = cost['supplier']  # 公司
            date = cost['updatetime']  # 日期
            timeArray = int(time.mktime(time.strptime(date, '%Y-%m')))
            fac_tax_pre = cost['facTaxPrevious']  # 市场价(含税) 上月
            fac_tax_avg = cost['facTaxAverage']  # 市场价(含税) 平均
            fac_tax_hight = cost['facTaxHighest']  # 市场价(含税) 最大值
            fac_tax_low = cost['facTaxLowest']  # 市场价(含税) 最小值
            current_tax_fac = cost['currentPriceFacTax']  # 市场价(含税)

            fac_pre = cost['facPrevious']  # 市场价(除税) 上月
            fac_avg = cost['facAverage']  # 市场价(除税) 平均
            fac_hight = cost['facHighest']  # 市场价(除税) 最大值
            fac_low = cost['facLowest']  # 市场价(除税) 最小值
            current_fac = cost['currentPriceFac']  # 市场价(除税)

            ref_tax_pre = cost['refTaxPrevious']  # 建议价(含税) 上月
            ref_tax_avg = cost['refTaxAverage']  # 建议价(含税) 平均
            ref_tax_hight = cost['refTaxHighest']  # 建议价(含税) 最大值
            ref_tax_low = cost['refTaxLowest']  # 建议价(含税) 最小值
            current_tax_ref = cost['currentPriceRefTax']  # 建议价(含税)

            ref_pre = cost['refPrevious']  # 建议价(除税) 上月
            ref_avg = cost['refAverage']  # 建议价(除税) 平均
            ref_hight = cost['refHighest']  # 建议价(除税) 最大值
            ref_low = cost['refLowest']  # 建议价(除税) 最小值
            current_ref = cost['currentPriceRef']  # 建议价(除税)

            spec = cost['spec']  # 商品类型
            rate = cost['taxRate']  # 税率
            main_title = title + "&nbsp;&nbsp;&nbsp;" + spec + "&nbsp;&nbsp;&nbsp;"
            pre_content = '<p><table border="1" cellspacing="0" style="width:100%;text-align:center;"><tr>供应商:' + company + '</tr> <tr><td>名称</td><td>规格型号</td><td>品牌</td><td>单位</td><td>城市</td><td>更新时间</td></tr><tr><td>' + title + '</td><td>' + spec + '</td><td>' + brand + '</td><td>' + unit + '</td><td>' + city + '</td><td>' + date + '</td></tr></table><table border="1" cellspacing="0" style="width:100%;text-align:center;"><tr>市场价(含税)</tr><tr><td>当前价格</td><td>上月价格</td><td>平均价格</td><td>最高价格</td><td>最低价格</td><td>税率</td></tr><tr><td>' + str(
                current_tax_fac) + '</td><td>' + str(fac_tax_pre) + '</td><td>' + str(fac_tax_avg) + '</td><td>' + str(
                fac_tax_hight) + '</td><td>' + str(
                fac_tax_low) + '</td><td>'+rate+'</td></tr></table><table border="1" cellspacing="0" style="width:100%;text-align:center;"><tr>市场价(除税)</tr><tr><td>当前价格</td><td>上月价格</td><td>平均价格</td><td>最高价格</td><td>最低价格</td><td>税率</td></tr><tr><td>' + str(
                current_fac) + '</td><td>' + str(fac_pre) + '</td><td>' + str(fac_avg) + '</td><td>' + str(
                fac_hight) + '</td><td>' + str(fac_low) + '</td><td>'+rate+'</td></tr></table>' \
                                                          '<table border="1" cellspacing="0" style="width:100%;text-align:center;"><tr>建议价(含税)</tr><tr><td>当前价格</td><td>上月价格</td><td>平均价格</td><td>最高价格</td><td>最低价格</td><td>税率</td></tr><tr><td>' + str(
                current_tax_ref) + '</td><td>' + str(ref_tax_pre) + '</td><td>' + str(ref_tax_avg) + '</td><td>' + str(
                ref_tax_hight) + '</td><td>' + str(ref_tax_low) + '</td><td>'+rate+'</td></tr></table>' \
                                                                  '<table border="1" cellspacing="0" style="width:100%;text-align:center;"><tr>建议价(除税)</tr><tr><td>当前价格</td><td>上月价格</td><td>平均价格</td><td>最高价格</td><td>最低价格</td><td>税率</td></tr><tr><td>' + str(
                current_ref) + '</td><td>' + str(ref_pre) + '</td><td>' + str(ref_avg) + '</td><td>' + str(
                ref_hight) + '</td><td>' + str(ref_low) + '</td><td>'+rate+'</td></tr></table></table></p>'

            insert_title = "insert into pre_portal_article_title (catid,bid,uid,username,title,highlight,author,`from`,`fromurl`," \
                           "url,summary,pic,thumb," \
                           "remote,id,idtype,contents,allowcomment,owncomment,click1,click2,click3,click4," \
                           "click5,click6,click7,click8,tag,dateline,status,showinnernav,preaid,nextaid,htmlmade,htmlname,htmldir) VALUES " \
                           "('%d','%d','%d','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d','%d','%d','%s','%d','%d','%d','%d','%d','%d','%d'" \
                           ", '%d', '%d', '%d', '%d', '%d','%d', '%d', '%d', '%d', '%d', '%d', '%s', '%s')" % \
                           (9, 0, 1, 'admin', main_title, '|||', '', '', '', '', '', '', 0, 0, 0, '', 1, 1, 0, 0, 0, 0,
                            0, 0, 0, 0, 0, 0, timeArray, 0, 0, 0, 0, 0, '', '')
            mh.cud(insert_title)
            max_id = mh.find(select_max_sql)
            id = int(max_id[0]['id'])
            insert_content = "insert into pre_portal_article_content (aid, id, idtype, title, content, pageorder, dateline" \
                             ") VALUES ('%d','%d','%s','%s','%s','%d','%d')" % (
                                 id, 0, '', '', pre_content.strip(), 1, timeArray)
            mh.cud(insert_content)