Exemple #1
0
 def commoditySource(self):  #商品来源
     self.click1('div>ul[class="menuList"] span', '商品来源')
     time.sleep(3)
     self.driver.find_element_by_xpath("//span[text()='1天']/..").click()
     with open('parameter.txt', 'r') as ff:
         f = ff.readlines()
     b = eval(f[0])
     for i in b['流量商品来源id']:
         self.driver.find_element_by_css_selector(
             'div>span[class*="sycm-common-select"]').click()
         time.sleep(1)
         e = self.driver.find_element_by_css_selector('div>span>input')
         e.click()
         time.sleep(0.5)
         e.send_keys(i)
         time.sleep(1)
         self.driver.find_element_by_css_selector(
             'div.oui-typeahead-dropdown>div>span').click()
         time.sleep(2)
         self.driver.find_element_by_xpath("//a/span[text()='下载']").click()
         time.sleep(5)
         j = './xiazai' + '\\' + os.listdir('xiazai')[0]
         data = xlrd.open_workbook(j)
         table = data.sheets()[0]
         nrows = table.nrows
         li = [table.row_values(i) for i in range(6, nrows)]
         t = '%s-%s-%s' % time.localtime()[:3]
         li = [[t + '[%s]' % i + j[0]] + j[1:] for j in li
               if re.findall('[1-9]', str(j[2:]))]
         b = currency.sqlite_weiwei('BS_Data_qplxbqjd.db')
         sql = '''create table commodity_Flow (
         日期来源 primary key not null default "",
         访客数 text not null default "",
         浏览量 text not null default "",
         浏览量占比 text not null default "",
         店内跳转人数 text not null default "",
         跳出本店人数 text not null default "",
         收藏人数 text not null default "",
         加购人数 text not null default "",
         下单买家数 text not null default "",
         下单转化率 text not null default "",
         支付件数 text not null default "",
         支付买家数 text not null default "",
         支付金额 text not null default "",
         支付转化率 text not null default "")'''
         try:
             b.zengShanGai(sql)
         except:
             pass  #首次创建表
         sql = "insert into commodity_Flow values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
         for i in li:
             try:
                 b.zengShanGai(sql, i)
             except:
                 pass
         shutil.rmtree("xiazai")
         b.conn.close()
Exemple #2
0
 def shopSource(self):  #店铺来源
     self.click1('div>ul[class="menuList"] span', '店铺来源')
     time.sleep(3)
     self.driver.find_element_by_xpath("//span[text()='1天']/..").click()
     time.sleep(2)
     self.driver.find_element_by_xpath("//a/span[text()='下载']").click()
     time.sleep(5)
     j = './xiazai' + '\\' + os.listdir('xiazai')[0]
     data = xlrd.open_workbook(j)
     table = data.sheets()[0]
     nrows = table.nrows
     li = [table.row_values(i) for i in range(6, nrows)]
     t = '%s-%s-%s' % time.localtime()[:3]
     li = [[t + ''.join(i[:2])] + i[2:] for i in li
           if re.findall('[1-9]', str(i[2:]))]
     b = currency.sqlite_weiwei('BS_Data_qplxbqjd.db')
     sql = '''create table Shop_Flow (
     日期来源 primary key not null default "",
     访客数 text not null default "",
     访客数变化 text not null default "",
     下单金额 text not null default "",
     下单金额变化 text not null default "",
     下单买家数 text not null default "",
     下单买家数变化 text not null default "",
     下单转化率 text not null default "",
     下单转化率变化 text not null default "",
     支付金额 text not null default "",
     支付金额变化 text not null default "",
     支付买家数 text not null default "",
     支付买家数变化 text not null default "",
     支付转化率 text not null default "",
     支付转化率变化 text not null default "",
     客单价 text not null default "",
     客单价变化 text not null default "",
     UV价值 text not null default "",
     uv价值变化 text not null default "",
     关注店铺买家数 text not null default "",
     关注店铺买家数变化 text not null default "",
     收藏商品买家数 text not null default "",
     收藏商品买家数变化 text not null default "",
     加购人数 text not null default "",
     加购人数变化 text not null default "",
     新访客 text not null default "",
     新访客变化 text not null default "")'''
     try:
         b.zengShanGai(sql)
     except:
         pass  #首次创建表
     sql = "insert into Shop_Flow values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
     for i in li:
         try:
             b.zengShanGai(sql, i)
         except:
             pass
     shutil.rmtree("xiazai")
     b.conn.close()
Exemple #3
0
def chashuju(tableName, field, condition):
    b = currency.sqlite_weiwei('BS_Data_qplxbqjd.db')
    sql = "select * from %s where %s like '%%%s%%'" % (
        tableName, field, condition)  #%%感觉有点类似转义
    #sql="select * from commodity_Flow where 日期来源 like '%%%s%%'"% riqi
    c = b.chaXun(sql)
    sql = 'pragma table_info(%s)' % tableName
    bt = [i[1] for i in b.chaXun(sql)]
    b.conn.close()
    return c, bt
    def goodsSourceOfEntry(self, i):  #竟品入店来源
        llrx = self.driver.find_element_by_css_selector(
            '#sycm-mc-flow-analysis')  #定位入店来源
        self.driver.execute_script('(arguments[0]).scrollIntoView()',
                                   llrx)  #滚动到指定元素
        for j in range(5):
            self.driver.find_element_by_xpath("//body").send_keys(Keys.UP)
        time.sleep(3)
        t = '%s-%s-%s' % time.localtime()[:3]
        li = ['访客数', '客群指数', '支付转化指数', '交易指数']
        self.driver.find_element_by_css_selector(
            '#sycm-mc-flow-analysis   div.oui-card-header>div> div').click()
        time.sleep(2)
        self.driver.find_element_by_css_selector(
            'div[data-reactroot]>div:not([class*="hidden"])>div>ul>li:nth-child(2)'
        ).click()
        time.sleep(2)
        data = self.sourceOfEntry1()
        li1 = []
        for j in data:
            li2 = [t + '无线端' + i + j]
            for p in li:
                if p in data[j]: li2 += [data[j][p]]
                else: li2 += ['0']
            li1 += [li2]

        self.driver.find_element_by_css_selector(
            '#sycm-mc-flow-analysis   div.oui-card-header>div> div').click()
        time.sleep(2)
        self.driver.find_element_by_css_selector(
            'div[data-reactroot]>div:not([class*="hidden"])>div>ul>li:nth-child(1)'
        ).click()
        time.sleep(2)
        data = self.sourceOfEntry1()
        for j in data:
            li2 = [t + 'PC端' + i + j]
            for p in li:
                if p in data[j]: li2 += [data[j][p]]
                else: li2 += ['0']
            li1 += [li2]
        l02 = ['日期来源商品id项目'] + li
        b = currency.sqlite_weiwei()
        sql = b.sql01('goodssourceOfEntry', l02)  #引流关键词
        try:
            b.addDelUpd(sql)
        except:
            pass
        sql = "insert into goodssourceOfEntry values(?,?,?,?,?)"
        for j in li1:
            try:
                b.addDelUpd(sql, j)
            except:
                pass
        b.cursor.close()
Exemple #5
0
 def commoditySource1(self, pcwx):  #商品来源
     with open('parameter.txt', 'r') as ff:
         f = ff.readlines()
     b = eval(f[0])
     for i in b['流量商品来源id']:
         self.driver.find_element_by_css_selector(
             'div>span[class*="sycm-common-select"]').click()
         time.sleep(0.5)
         self.shuru1(i)
         time.sleep(2)
         self.driver.find_element_by_xpath("//a/span[text()='下载']").click()
         time.sleep(5)
         j = './xiazai' + '\\' + os.listdir('xiazai')[0]
         data = xlrd.open_workbook(j)
         table = data.sheets()[0]
         nrows = table.nrows
         li = [table.row_values(i) for i in range(6, nrows)]  #所有的数据行
         table_title = table.row_values(5)  #表头行
         t = '%s-%s-%s' % time.localtime()[:3]
         l01 = []  #所有数据【{},{}。。。】
         for k in li:
             data = {}
             for j in range(len(k)):  #i是一行数据
                 if j == 0: data['日期来源'] = t + pcwx + '【%s】' % i + k[j]
                 else: data[table_title[j]] = k[j]
             l01.append(data)
         l02 = [
             '日期来源', '访客数', '浏览量', '浏览量占比', '店内跳转人数', '跳出本店人数', '收藏人数',
             '加购人数', '下单买家数', '下单转化率', '支付件数', '支付买家数', '支付金额', '支付转化率',
             '直接支付买家数', '收藏商品-支付买家数', '粉丝支付买家数', '加购商品-支付买家数'
         ]
         b = currency.sqlite_weiwei()
         sql = b.sql01('commodity_Flow', l02)
         try:
             b.addDelUpd(sql)
         except:
             pass  #首次创建表
         l03 = []
         for k in l01:
             l04 = []
             for j in l02:
                 if j in k: l04.append(k[j])
                 else: l04.append('')
             l03 = l03 + [l04]
         sql = "insert into commodity_Flow values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
         l03 = [i for i in l03 if re.findall('[1-9]', str(i[1:]))]
         for i in l03:
             try:
                 b.addDelUpd(sql, i)
             except:
                 pass
         shutil.rmtree("xiazai")
         b.conn.close()
Exemple #6
0
 def cruxIndex(self, i):  #关键指标
     b_cruxIndex = self.driver.find_elements_by_css_selector(
         'div>div.alife-one-design-sycm-indexes-trend-index-container>div>div'
     )
     b_cruxIndex1 = [i.text.split('\n') for i in b_cruxIndex]
     try:
         self.driver.find_element_by_css_selector(
             'div>div>i[class*="right"]').click()
     except:
         self.driver.find_element_by_css_selector(
             'div>div>i[class*="left"]').click()
     time.sleep(1)
     b_cruxIndex = self.driver.find_elements_by_css_selector(
         'div>div.alife-one-design-sycm-indexes-trend-index-container>div>div'
     )
     b_cruxIndex = [i.text.split('\n') for i in b_cruxIndex]
     b_cruxIndex = b_cruxIndex1 + b_cruxIndex
     t = '%s-%s-%s' % time.localtime()[:3]
     b_data = {j[0]: [j[2], j[4]] for j in b_cruxIndex}  #数据转为字典
     l02 = [
         '店铺日期', '交易指数', '流量指数', '搜索人气', '收藏人气', '加购人气', '预售定金交易指数',
         '预售支付商品件数', '上新商品数', '支付转化指数', '客群指数'
     ]
     b = currency.sqlite_weiwei()
     sql = b.sql01('cruxIndex', l02)
     try:
         b.addDelUpd(sql)
     except:
         pass
     bd = self.driver.find_element_by_css_selector(
         'span.ebase-Selector__title').text  #本店名称
     l03, l04 = [], []
     for j in l02:
         if j == '店铺日期':
             l03 += [t + bd]
             l04 += [t + i]
         else:
             try:
                 l03 += [b_data[j][0]]
             except:
                 return
             l04 += [b_data[j][1]]
     sql = "insert into cruxIndex values(?,?,?,?,?,?,?,?,?,?,?)"
     try:
         b.addDelUpd(sql, l03)
     except:
         pass
     try:
         b.addDelUpd(sql, l04)
     except:
         currency.Ri_zhi()
     b.cursor.close()
Exemple #7
0
 def shopSource1(self, pcwx):  #店铺来源下载和保存
     self.driver.find_element_by_xpath("//a/span[text()='下载']").click()
     time.sleep(5)
     j = './xiazai' + '\\' + os.listdir('xiazai')[0]
     data = xlrd.open_workbook(j)
     table = data.sheets()[0]
     nrows = table.nrows
     table_title = table.row_values(5)  #6行的列表
     li = [table.row_values(i) for i in range(6, nrows)]  #6行后所有行的列表
     t = '%s-%s-%s' % time.localtime()[:3]
     l01 = []
     for i in li:
         data = {}
         for j in range(1, len(i)):
             if j == 1: data['日期来源'] = t + pcwx + ''.join(i[:2])
             else: data[table_title[j]] = i[j]
         l01.append(data)
     l02 = [
         '日期来源', '访客数', '访客数变化', '下单金额', '下单金额变化', '下单买家数', '下单买家数变化',
         '下单转化率', '下单转化率变化', '支付金额', '支付金额变化', '支付买家数', '支付买家数变化', '支付转化率',
         '支付转化率变化', '客单价', '客单价变化', 'UV价值', 'uv价值变化', '关注店铺买家数',
         '关注店铺买家数变化', '收藏商品买家数', '收藏商品买家数变化', '加购人数', '加购人数变化', '新访客',
         '新访客变化', '收藏人数', '收藏人数变化', '跳失率', '跳失率变化', '浏览量', '浏览量变化', '人均浏览量',
         '人均浏览量变化', '粉丝支付买家数', '直接支付买家数', '加购商品-支付买家数', '收藏商品-支付买家数',
         '访客数环比'
     ]
     b = currency.sqlite_weiwei()
     sql = b.sql01('Shop_Flow', l02)
     try:
         b.addDelUpd(sql)
     except:
         pass  #首次创建表
     l03 = []
     for i in l01:
         l04 = []
         for j in l02:
             if j in i: l04.append(i[j])
             else: l04.append('')
         l03 = l03 + [l04]
     sql = "insert into Shop_Flow values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
     l03 = [i for i in l03 if re.findall('[1-9]', str(i[1:]))]
     for i in l03:
         try:
             b.addDelUpd(sql, i)
         except:
             pass
     shutil.rmtree("xiazai")
     b.conn.close()
    def drainageKeywords(self, i):  #引流关键词
        llrx = self.driver.find_element_by_css_selector(
            '#itemAnalysisKeyword')  #定位入店搜索词
        self.driver.execute_script('(arguments[0]).scrollIntoView()',
                                   llrx)  #滚动到指定元素
        for j in range(5):
            self.driver.find_element_by_xpath("//body").send_keys(Keys.UP)
        time.sleep(2)
        l02 = ['日期来源商品id词', '访客数']
        b = currency.sqlite_weiwei()
        sql = b.sql01('drainageKeywords', l02)  #引流关键词
        try:
            b.addDelUpd(sql)
        except:
            pass
        self.driver.find_element_by_xpath(
            "//*[@id='itemAnalysisKeyword']//span[text()='引流关键词']").click()
        time.sleep(1)
        li = self.shopSearchWords(i)
        sql = "insert into drainageKeywords values(?,?)"
        for j in li:
            try:
                b.addDelUpd(sql, j)
            except:
                pass

        l02 = ['日期来源商品id词', '交易指数']
        sql = b.sql01('transactionKeywords', l02)  #成交关键词
        try:
            b.addDelUpd(sql)
        except:
            pass
        self.driver.find_element_by_xpath(
            "//*[@id='itemAnalysisKeyword']//span[text()='成交关键词']").click()
        time.sleep(1)
        li = self.shopSearchWords(i)
        sql = "insert into transactionKeywords values(?,?)"
        for j in li:
            try:
                b.addDelUpd(sql, j)
            except:
                pass
        b.cursor.close()
 def goodsCruxIndex(self, i):  #竟品关键指标
     b_cruxIndex = self.driver.find_elements_by_css_selector(
         'div>div.alife-one-design-sycm-indexes-trend-index-container>div>div'
     )
     b_cruxIndex1 = [i.text.split('\n') for i in b_cruxIndex]
     b_cruxIndex1 = {i[0]: i[2] for i in b_cruxIndex1}
     time.sleep(1)
     try:
         self.driver.find_element_by_css_selector(
             'div>div>i[class*="right"]').click()
     except:
         self.driver.find_element_by_css_selector(
             'div>div>i[class*="left"]').click()
     time.sleep(1)
     b_cruxIndex = self.driver.find_elements_by_css_selector(
         'div>div.alife-one-design-sycm-indexes-trend-index-container>div>div'
     )
     b_cruxIndex = [i.text.split('\n') for i in b_cruxIndex]
     for j in b_cruxIndex:
         b_cruxIndex1[j[0]] = j[2]  #b_cruxIndex1为各指数为键,数值为值的字段
     t = '%s-%s-%s' % time.localtime()[:3]
     l02 = ['日期商品id', '交易指数', '流量指数', '搜索人气', '收藏人气', '加购人气', '支付转化指数']
     b = currency.sqlite_weiwei()
     sql = b.sql01('goodsCruxIndex', l02)
     try:
         b.addDelUpd(sql)
     except:
         pass
     l03 = []
     for j in l02:
         if j == '日期商品id':
             l03 += [t + '  ' + i]
         else:
             l03 += [b_cruxIndex1[j]]
     sql = "insert into goodsCruxIndex values(?,?,?,?,?,?,?)"
     try:
         b.addDelUpd(sql, l03)
     except:
         pass
     b.cursor.close()
Exemple #10
0
widget = QtWidgets.QWidget()
ui = AppMain.Ui_Form()
#ui.pushButton.clicked.connect(self.kaishi)
ui.setupUi(widget)
ui.pushButton_2.clicked.connect(lambda: b(driver))
ui.pushButton_3.clicked.connect(lambda: c(driver))
ui.pushButton_4.clicked.connect(lambda: d(driver))
widget.show()
sys.exit(app.exec_())

s0 = [['Shop_Flow', '店铺流量'], ['commodity_Flow', '商品来源']]  #flow.py#流量
s0 = [['cruxIndex', '关键指标'], ['commoditylist', 'TOP商品'],
      ['transactionComposition', '交易构成'], ['price_band', '价格带'],
      ['sourceOfEntry', '入店来源']]  #compete.py#竟店
s0 = [['goodsCruxIndex', '竟品关键指标'], ['drainageKeywords', '引流关键词'],
      ['transactionKeywords', '成交关键词'], ['goodsSourceOfEntry',
                                         '竟品入店来源']]  #competitive_goods.py#竟品

if 1:
    s = s0[0][0]
    print(s)
    e = currency.sqlite_weiwei()
    e.cursor.execute('pragma table_info(%s)' % s)
    lie = [i[1] for i in e.cursor.fetchall()]  #表头
    sql = "select * from %s where %s like '%%2019-8-8%%'" % (s, lie[0])
    hang = e.sel(sql)
    print(len(hang))
    for i1 in hang:
        print(i1)
    lie
Exemple #11
0
    def sourceOfEntry(self, i):  #入店来源
        t = '%s-%s-%s' % time.localtime()[:3]
        l02 = [
            '日期店铺来源', '流量指数', '客群指数', '支付转化指数', '交易指数', '访客数', '支付买家数',
            '支付转化率', '支付金额'
        ]
        b = currency.sqlite_weiwei()
        sql = b.sql01('sourceOfEntry', l02)
        try:
            b.addDelUpd(sql)
        except:
            pass  #首次创建表
        li = self.driver.find_elements_by_css_selector(
            '#sycm-mc-flow-analysis li')
        self.driver.execute_script('(arguments[0]).scrollIntoView()',
                                   li[0])  #滚动到指定元素
        for j in range(5):
            self.driver.find_element_by_xpath("//body").send_keys(Keys.UP)
        time.sleep(1)

        bd = self.driver.find_element_by_css_selector(
            'span.ebase-Selector__title').text  #本店名称
        Li = [{}, {}]
        for j in range(len(li)):
            self.driver.find_elements_by_css_selector(
                '#sycm-mc-flow-analysis input')[j].click()
            time.sleep(3)
            xm = li[j].text
            tbody = self.driver.find_element_by_css_selector(
                '#sycm-mc-flow-analysis tbody').text
            tbody = [i.split('\n') for i in tbody.split('\n趋势\n')]
            for k in tbody:
                if k[0] not in Li[0]: Li[0][k[0]] = {}
                if k[0] not in Li[1]: Li[1][k[0]] = {}
                Li[0][k[0]][xm] = k[1]
                Li[1][k[0]][xm] = k[2]
                Li[0][k[0]][xm] = k[1]
                Li[1][k[0]][xm] = k[2]
                if '流量' in xm:
                    Li[0][k[0]]['访客数'] = k[3]
                    Li[1][k[0]]['访客数'] = ''
                elif '客群' in xm:
                    Li[0][k[0]]['支付买家数'] = k[3]
                    Li[1][k[0]]['支付买家数'] = ''
                elif '支付' in xm:
                    Li[0][k[0]]['支付转化率'] = k[3]
                    Li[1][k[0]]['支付转化率'] = ''
                elif '交易' in xm:
                    Li[0][k[0]]['支付金额'] = k[3]
                    Li[1][k[0]]['支付金额'] = ''
        sql = "insert into sourceOfEntry values(?,?,?,?,?,?,?,?,?)"
        for o in Li[0]:  #Li[0]是字段,o是字段的键
            bdli = [t + bd + o]
            for u in l02[1:]:  #u是字典Li[0][o] 的键,也是字段名
                bdli += [Li[0][o][u]]
            if re.findall('[1-9]', str(bdli[1:])):
                try:
                    b.addDelUpd(sql, bdli)
                except:
                    pass
        for o in Li[1]:  #Li[0]是字段,o是字段的键
            jdli = [t + i + o]
            for u in l02[1:]:  #u是字典Li[0][o] 的键,也是字段名
                jdli += [Li[1][o][u]]
            if re.findall('[1-9]', str(jdli[1:])):
                try:
                    b.addDelUpd(sql, jdli)
                except:
                    pass
        b.cursor.close()
Exemple #12
0
    def transactionComposition(self, i):  #交易构成
        t = '%s-%s-%s' % time.localtime()[:3]
        l02 = ['日期店铺排名', '类目', '支付金额占比']
        b = currency.sqlite_weiwei()
        sql = b.sql01('transactionComposition', l02)
        try:
            b.addDelUpd(sql)
        except:
            pass  #首次创建表
        b_jygc = self.driver.find_element_by_css_selector(
            '#shopAnalysisTrade>div.oui-card-content')  #交易构成
        self.driver.execute_script('(arguments[0]).scrollIntoView()',
                                   b_jygc)  #滚动到指定元素
        for j in range(5):
            self.driver.find_element_by_xpath("//body").send_keys(Keys.DOWN)
        time.sleep(1)

        css01 = '#shopAnalysisTrade>div.oui-card-content>div:nth-child(%s)>div:nth-child(%s) tr'
        b_lmzbbd = self.driver.find_elements_by_css_selector(css01 %
                                                             (1, 1))  #类目占比本店
        b_lmzbjd = self.driver.find_elements_by_css_selector(css01 %
                                                             (1, 2))  #类目占比竟店
        b_jgdzbbd = self.driver.find_elements_by_css_selector(css01 %
                                                              (2, 1))  #价格带占比本店
        b_jgdzbjd = self.driver.find_elements_by_css_selector(css01 %
                                                              (2, 2))  #价格带占比竟店
        bd = self.driver.find_element_by_css_selector(
            'span.ebase-Selector__title').text  #本店名称
        sql = "insert into transactionComposition values(?,?,?)"
        for j in range(len(b_lmzbbd)):
            if j == 0: continue
            data = b_lmzbbd[j].text
            data = data.split('\n')
            try:
                b.addDelUpd(sql, [t + bd + data[0], data[1], data[2]])
            except:
                pass
        for j in range(len(b_lmzbjd)):
            if j == 0: continue
            data = b_lmzbjd[j].text
            data = data.split('\n')
            try:
                b.addDelUpd(sql, [t + i + data[0], data[1], data[2]])
            except:
                pass

        l02 = ['日期店铺编号', '价格带', '支付金额占比']
        sql = b.sql01('price_band', l02)
        try:
            b.addDelUpd(sql)
        except:
            pass  #首次创建表
        sql = "insert into price_band values(?,?,?)"
        for j in range(len(b_jgdzbbd)):
            if j == 0: continue
            data = b_jgdzbbd[j].text
            data = data.split('\n')
            try:
                b.addDelUpd(sql, [t + bd + str(j), data[0], data[1]])
            except:
                pass
        for j in range(len(b_jgdzbjd)):
            if j == 0: continue
            data = b_jgdzbjd[j].text
            data = data.split('\n')
            try:
                b.addDelUpd(sql, [t + i + str(j), data[0], data[1]])
            except:
                pass
        b.cursor.close()
Exemple #13
0
 def commodityList(self, i):  #TOP商品榜
     t = '%s-%s-%s' % time.localtime()[:3]
     l02 = ['店铺日期商品id项目', 'top排名', '指数', '较前一日']
     b = currency.sqlite_weiwei()
     sql = b.sql01('commodityList', l02)
     try:
         b.addDelUpd(sql)
     except:
         pass  #首次创建表
     llrx = self.driver.find_elements_by_css_selector(
         '#shopAnalysisItems div>div>div>span>span')  #定位浏览热销
     self.driver.execute_script('(arguments[0]).scrollIntoView()',
                                llrx[0])  #滚动到指定元素
     time.sleep(1)
     for j in range(5):
         self.driver.find_element_by_xpath("//body").send_keys(Keys.UP)
     time.sleep(0.5)
     for j in range(2):
         if j == 0: rl = '热销'
         else: rl = '流量'
         self.driver.find_elements_by_css_selector(
             '#shopAnalysisItems div>div>div>span>span')[j].click()  #定位浏览热销
         time.sleep(2)
         # 店铺top前十
         sql = "insert into commodityList values(?,?,?,?)"
         td1 = self.driver.find_elements_by_css_selector(
             '#shopAnalysisItems>div>div>div:nth-child(1) tbody td:nth-child(1)'
         )
         td2 = self.driver.find_elements_by_css_selector(
             '#shopAnalysisItems>div>div>div:nth-child(1) tbody td:nth-child(2)'
         )
         bd = self.driver.find_element_by_css_selector(
             'span.ebase-Selector__title').text  #本店名称
         num = 1
         for td in zip(td1, td2):
             id1 = re.findall('id=(\d+)" target',
                              td[0].get_attribute("outerHTML"))[0]
             ourShop = [t + bd + id1 + rl]  #时间店铺id项目
             zhsh = td[1].text
             ourShop += [str(num)] + zhsh.split('\n')
             num += 1
             try:
                 b.addDelUpd(sql, ourShop)
             except:
                 pass
         # 竟店top前十
         td1 = self.driver.find_elements_by_css_selector(
             '#shopAnalysisItems>div>div>div:nth-child(2) tbody td:nth-child(1)'
         )
         td2 = self.driver.find_elements_by_css_selector(
             '#shopAnalysisItems>div>div>div:nth-child(2) tbody td:nth-child(2)'
         )
         num = 1
         for td in zip(td1, td2):
             id1 = re.findall('id=(\d+)" target',
                              td[0].get_attribute("outerHTML"))[0]
             competitiveStores = [t + i + id1 + rl]  #时间店铺id项目
             zhsh = td[1].text
             competitiveStores += [str(num)] + zhsh.split('\n')
             num += 1
             try:
                 b.addDelUpd(sql, competitiveStores)
             except:
                 pass
     b.cursor.close()