当前位置: 首页>>代码示例>>Python>>正文


Python DBManager.insert_into_table方法代码示例

本文整理汇总了Python中DBManager.DBManager.insert_into_table方法的典型用法代码示例。如果您正苦于以下问题:Python DBManager.insert_into_table方法的具体用法?Python DBManager.insert_into_table怎么用?Python DBManager.insert_into_table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBManager.DBManager的用法示例。


在下文中一共展示了DBManager.insert_into_table方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: namotoring_user_grab

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import insert_into_table [as 别名]
def namotoring_user_grab(url, userdb = 'namotoring_users', debug = False):
    bimm = namotoring()
    main_page = xmlTree_w_login(url,'vb', 'somebody', 'anybody')
    userdata = []
    #pdb.set_trace()
    if main_page:
            if not debug:
                udb = DBManager()
            if len(main_page.xpath(bimm.location))>0:
                #print bimm.get_location(main_page.xpath(bimm.location)[0].text_content().strip())
                userdata.append(('Location',bimm.get_location(main_page.xpath(bimm.location)[0].text_content().strip())))
                #if len(main_page.xpath(bimm.cars))>0:
                #  print main_page.xpath(bimm.cars)[0].text_content()
            if len(main_page.xpath(bimm.interests))>0:
                #print main_page.xpath(bimm.interests)[0].text_content()
                userdata.append(('Interests',main_page.xpath(bimm.interests)))
            if len(main_page.xpath(bimm.noposts))>0:
                #print bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())
                userdata.append(('TotalPosts',bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())[0]))
                userdata.append(('PostsPerDay',bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())[1]))
            if len(main_page.xpath(bimm.lastac))>0:
                #print bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content())
                userdata.append(('LastActivity',bimm.convert_to_valid_date(bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content()))))
            if len(main_page.xpath(bimm.joindate))>0:
                #print bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content())
                userdata.append(('JoinDate',bimm.convert_to_valid_date(bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content()))))
                #if len(main_page.xpath(bimm.ppday))>0:
                #  print bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())
                #if len(main_page.xpath(bimm.cars))>0:
                #  print bimm.get_cars(main_page.xpath(bimm.cars)[0])
            if len(main_page.xpath(bimm.handle))>0:
                #print main_page.xpath(bimm.handle)[0].text_content()
                userdata.append(('Handle',main_page.xpath(bimm.handle)[0].text_content().strip()))
                #if len(main_page.xpath(bimm.bio))>0:
                #  print main_page.xpath(bimm.bio)[0].text_content()
            if len(main_page.xpath(bimm.occupation))>0:
                #print main_page.xpath(bimm.occupation)[0].text_content()
                try:
                    userdata.append(('Occupation',main_page.xpath(bimm.occupation)[0].text_content()))
                except AttributeError:
                    userdata.append(('Occupation',main_page.xpath(bimm.occupation)[0]))
            if len(main_page.xpath(bimm.ulink))>0:
                #print main_page.xpath(bimm.ulink)[0].text_content()
                userdata.append(('Link',main_page.xpath(bimm.ulink)[0].text_content()))
            if len(main_page.xpath(bimm.name))>0:
                #print bimm.get_name_email(main_page.xpath(bimm.name)[0])
                userdata.append(('Name',bimm.get_name_email(main_page.xpath(bimm.name)[0])))
                #print userdata
            if len(main_page.xpath(bimm.plus_fb))>0:
                userdata.append(('PositiveFeedback', main_page.xpath(bimm.plus_fb)[0].text_content().strip()))
            if len(main_page.xpath(bimm.minus_fb))>0:
                userdata.append(('NegativeFeedback', diff(main_page.xpath(bimm.minus_fb)[0].text_content().strip(),\
                                                          main_page.xpath(bimm.plus_fb)[0].text_content().strip())))
            if not debug:
                udb.insert_into_table(userdb, userdata)
                udb.close()
            else:
                print userdata
    else:
        pass
开发者ID:hackaway,项目名称:forum,代码行数:62,代码来源:namotoring_grabber.py

示例2: audiworld_user_grab

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import insert_into_table [as 别名]
def audiworld_user_grab(url, userdb = 'audiworld_users', debug = True):
    bimm = audiworld()
    main_page = xmlTree(url)
    if main_page:
                    userdata = []
                    if not debug:
                        udb = DBManager()
                
                    if len(main_page.xpath(bimm.location))>0:
                        #print main_page.xpath(bimm.location)[0].text_content()
                        userdata.append(('Location',main_page.xpath(bimm.location)[0].text_content()))
                        #if len(main_page.xpath(bimm.cars))>0:
                        #  print main_page.xpath(bimm.cars)[0].text_content()
                
                    if len(main_page.xpath(bimm.interests))>0:
                        #print main_page.xpath(bimm.interests)[0].text_content()
                        userdata.append(('Interests',main_page.xpath(bimm.interests)[0].text_content()))
                
                    if len(main_page.xpath(bimm.noposts))>0:
                        #print bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())
                        userdata.append(('TotalPosts',bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())))
                                    
                    if len(main_page.xpath(bimm.lastac))>0:
                        #print bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content())
                        userdata.append(('LastActivity',bimm.convert_to_valid_date(bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content()))))
                                    
                    if len(main_page.xpath(bimm.joindate))>0:
                        #print bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content())
                        userdata.append(('JoinDate',bimm.convert_to_valid_date(bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content()))))
                
                    if len(main_page.xpath(bimm.ppday))>0:
                        #print bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())
                        userdata.append(('PostsPerDay',bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())))
                
                    if len(main_page.xpath(bimm.cars))>0:
                        #print bimm.get_cars(main_page.xpath(bimm.cars)[0])
                        userdata.append(('Cars',bimm.get_cars(main_page.xpath(bimm.cars)[0])))
                
                    if len(main_page.xpath(bimm.handle))>0:
                        #print main_page.xpath(bimm.handle)[0].text_content().strip()
                        userdata.append(('Handle',main_page.xpath(bimm.handle)[0].text_content().strip()))
                
                    if len(main_page.xpath(bimm.bio))>0:
                        #print main_page.xpath(bimm.bio)[0].text_content()
                        userdata.append(('Biography',main_page.xpath(bimm.bio)[0].text_content()))
                
                    if len(main_page.xpath(bimm.occupation))>0:
                        #print main_page.xpath(bimm.occupation)[0].text_content()
                        userdata.append(('Occupation',main_page.xpath(bimm.occupation)[0].text_content()))
                    if len(main_page.xpath(bimm.ulink))>0:
                        #print main_page.xpath(bimm.ulink)[0].text_content()
                        userdata.append(('Link',main_page.xpath(bimm.ulink)[0].text_content()))
                    if not debug:
                        udb.insert_into_table(userdb, userdata)
                        udb.close()   #@IndentOk
                    else:
                        print userdata
    else:
        pass
开发者ID:hackaway,项目名称:forum,代码行数:61,代码来源:audiworld_grabber.py

示例3: priuschat_user_grab

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import insert_into_table [as 别名]
def priuschat_user_grab(url, userdb='priuschat_users', debug = False):
    bimm = priuschat() 
    main_page = xmlTree(url)
    userdata = []
    #pdb.set_trace()
    if main_page:
            if not debug:
                udb = DBManager()
            if len(main_page.xpath(bimm.location))>0:
                #print main_page.xpath(bimm.location)[0].text_content().strip()
                userdata.append(('Location',main_page.xpath(bimm.location)[0].text_content().strip()))
            #if len(main_page.xpath(bimm.cars))>0:
                #  print main_page.xpath(bimm.cars)[0].text_content()
            if len(main_page.xpath(bimm.interests))>0:
                #print main_page.xpath(bimm.interests)[0].text_content()
                userdata.append(('Interests',main_page.xpath(bimm.interests)[0].text_content()))
            if len(main_page.xpath(bimm.noposts))>0:
                #print bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())
                userdata.append(('TotalPosts',bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())))
            if len(main_page.xpath(bimm.lastac))>0:
                #print bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content())
                userdata.append(('LastActivity',bimm.convert_to_valid_date(bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content()))))
            if len(main_page.xpath(bimm.joindate))>0:
                #print bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content())
                userdata.append(('JoinDate', bimm.convert_to_valid_date(bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content()))))
            if len(main_page.xpath(bimm.ppday))>0:
                #print bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())
                userdata.append(('PostsPerDay', bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())))
                  
            if len(main_page.xpath(bimm.cars))>0:
                #print main_page.xpath(bimm.cars)[0].text_content()
                userdata.append(('Cars',main_page.xpath(bimm.cars)[0].text_content()))
                  
            if len(main_page.xpath(bimm.handle))>0:
                #print main_page.xpath(bimm.handle)[0].text_content()
                userdata.append(('Handle',main_page.xpath(bimm.handle)[0].text_content()))
                #if len(main_page.xpath(bimm.bio))>0:
                #  print main_page.xpath(bimm.bio)[0].text_content()
            if len(main_page.xpath(bimm.occupation))>0:
                #print main_page.xpath(bimm.occupation)[0].text_content()
                userdata.append(('Occupation',main_page.xpath(bimm.occupation)[0].text_content()))
            if len(main_page.xpath(bimm.ulink))>0:
                #print main_page.xpath(bimm.ulink)[0].text_content()
                userdata.append(('Link', main_page.xpath(bimm.ulink)[0].text_content()))
                #if len(main_page.xpath(bimm.name))>0:
                #  print bimm.get_name_email(main_page.xpath(bimm.name)[0])
                #print userdata
            if not debug:
                udb.insert_into_table(userdb, userdata)
                udb.close()
            else:
                print userdata
    else:
        pass
开发者ID:hackaway,项目名称:forum,代码行数:56,代码来源:priuschat_grabber.py

示例4: vwvortex_grab

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import insert_into_table [as 别名]
def vwvortex_grab(threaddb = 'vwvortex_threads', debug = True):
    #      pdb.set_trace()
    bmw = vwvortex()
    main_page = xmlTree(bmw.domain)
    lvl1 = main_page.xpath(bmw.linklist_lvl1)
    if not debug:
        udb = DBManager()
    for lvl1_link in lvl1:
        second_lvl_page = xmlTree(bmw.domain+lvl1_link)
        lvl2 = second_lvl_page.xpath(bmw.linklist_lvl2)
        for lvl2_link in lvl2:
            next_page = xmlTree(bmw.domain+lvl2_link+alltime)
            while True:
                try:
                    next = next_page.xpath(bmw.next_link)[0]
                except IndexError:
                    next = None
                threads = next_page.xpath(bmw.threads_list)
                tread_data = next_page.xpath(bmw.threaddata)
                for j in tread_data:
                    #pass
                    if j.xpath(bmw.description):
                        threaddata = []
                        threaddata.append(('Description', j.xpath(bmw.description)[0].text_content().encode('utf-8')))
                        #print j.xpath(bmw.description)[0].text_content().encode('utf-8')
                        threaddata.append(('Replies', j.xpath(bmw.replies)[0].text_content()))
                        #print j.xpath(bmw.replies)[0].text_content()
                        threaddata.append(('Views', bmw.parse_views(j.xpath(bmw.views)[0].text_content())['Views']))
                        #print bmw.parse_views(j.xpath(bmw.views)[0].text_content())
                        threaddata.append(('Link', j.xpath(bmw.link)[0].encode('utf-8')))
                        #print j.xpath(bmw.link)[0].encode('utf-8')
                        #print bmw.thread_id(j.xpath(bmw.link)[0].encode('utf-8'))
                        
                        vwvortex_thread_grab(bmw.domain+j.xpath(bmw.link)[0].encode('utf-8'))
                        if not debug:
                            udb.insert_into_table(threaddb, threaddata)
                        else:
                            print threaddata
                        #vwvortex_thread_grab()
#            for k in threads:
#                pass
                #                print k
                    if next:
                        next_page = xmlTree(bmw.domain+next)
            
                    elif not next:
                        break
    if not debug:
        udb.close()
开发者ID:hackaway,项目名称:forum,代码行数:51,代码来源:vwvortex_grabber.py

示例5: feoa_thread_grab

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import insert_into_table [as 别名]
def feoa_thread_grab(url, postsdb = 'feoa_posts', debug = True):
    bimm = feoa()
    next_page = xmlTree(url)
    #posts = main_page
    if not debug:
        udb = DBManager()
    while True:
        try:
            next = next_page.xpath(bimm.next_link)[0]
            #print next
        except IndexError:
            next = None
        posts = next_page.xpath(bimm.postdata)
        for t in posts:
            if t.xpath(bimm.posterid):
                threaddata = []
                #print '**********************************************************************'
                threaddata.append(('TimeOfPost',bimm.convert_to_valid_date(bimm.time_of_post(\
                                        t.xpath(bimm.timeofpost)[0].text_content().strip()))))
                #print t.xpath(bimm.timeofpost)[0].text_content().strip()
                threaddata.append(('PosterID',bimm.poster_id(t.xpath(bimm.posterid)[0])))
                #print bimm.poster_id(t.xpath(bimm.posterid)[0])#[0].text_content()
                threaddata.append(('PostID',bimm.post_id(t.xpath(bimm.postid)[0])))
                #print bimm.post_id(t.xpath(bimm.postid)[0])#[0].text_content()
                threaddata.append(('ThreadID', bimm.thread_id(t.xpath(bimm.post_thread)[0])))
                try:
                    threaddata.append(('PostCountInThread',t.xpath(bimm.postcount)[0].text_content()))
                    #print t.xpath(bimm.postcount)[0].text_content()
                except AttributeError:
                    threaddata.append(('PostCountInThread',t.xpath(bimm.postcount)[0]))
                    #print t.xpath(bimm.postcount)[0]
                except IndexError:
                    pass
                threaddata.append(('Link',t.xpath(bimm.postlink)[0] ))
                feoa_user_grab(bimm.domain+t.xpath(bimm.posterid)[0], 'feoa_users')
                if not debug:
                    udb.insert_into_table(postsdb, threaddata)
                else:
                    print threaddata
                #print t.xpath(bimm.postlink)#[0].text_content()
                #print '**********************************************************************'
        if next:
            #pdb.set_trace() 
            next_page = xmlTree(bimm.domain+next+alltime)
        elif not next:
            if not debug:
                udb.close()
            break
开发者ID:hackaway,项目名称:forum,代码行数:50,代码来源:feoa_grabber.py

示例6: audiworld_grab

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import insert_into_table [as 别名]
def audiworld_grab(threaddb = 'audiworld_threads', debug  = True):
    bmw = audiworld()
    main_page = xmlTree(bmw.domain)
    lvl1 = main_page.xpath(bmw.linklist)
    if not debug:
        udb = DBManager()
    for lvl1_link in lvl1:
#        print lvl1_link
        next_page = xmlTree(bmw.domain+lvl1_link+alltime)
        #next_page = xmlTree(lvl1_link)
#        print bmw.domain+lvl1_link
        #next = next_page.xpath(bmw.next_link)[0]
        while True:
            try:
                next = next_page.xpath(bmw.next_link)[0]
            except IndexError:
                next = None
            threads = next_page.xpath(bmw.threads_list)
            tread_data = next_page.xpath(bmw.threaddata)
            for j in tread_data:
                #pass
                threaddata = []
                if j.xpath(bmw.description):
                    threaddata.append(('Description',j.xpath(bmw.description)[0].text_content().encode('utf-8')))
                    #print j.xpath(bmw.description)[0].text_content().encode('utf-8')
                    threaddata.append(('Replies', j.xpath(bmw.replies)[0].text_content()))
                    #print j.xpath(bmw.replies)[0].text_content()
                    threaddata.append(('Views', j.xpath(bmw.views)[0].text_content()))
                    #print j.xpath(bmw.views)[0].text_content()
                    threaddata.append(('Link', j.xpath(bmw.link)[0]))
                    #print j.xpath(bmw.link)[0]
                    threaddata.append(('ThreadID', bmw.thread_id(j.xpath(bmw.link)[0]) ))
                    #print bmw.thread_id(j.xpath(bmw.link)[0])
                    audiworld_thread_grab(bmw.domain+j.xpath(bmw.link)[0])
                    if not debug:
                        udb.insert_into_table(threaddb, threaddata)
                    else:
                        print threaddata
            for k in threads:
                pass
                print k
            if next:
                next_page = xmlTree(bmw.domain+next+alltime)
            
            elif not next:
                break
    if not debug:
        udb.close()
开发者ID:hackaway,项目名称:forum,代码行数:50,代码来源:audiworld_grabber.py

示例7: mazda3_grab

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import insert_into_table [as 别名]
def mazda3_grab(threaddb = 'mazda3_threadas', debug =True):
    #pdb.set_trace()
    bmw = mazda3()
    main_page = xmlTree(bmw.domain)
    lvl1 = main_page.xpath(bmw.linklist)
    if not debug:
        udb = DBManager()
    for lvl1_link in lvl1:
        next_page = xmlTree(lvl1_link)
        count = 0
        pos = lvl1_link.find('board=') + len('board=')
        part = lvl1_link[:pos]
        fid = lvl1_link[pos:]
        ifid = fid.split(r'.')
    
        try:
            lastpage = int(next_page.xpath(bmw.last_page_threads)[0].text_content())
        except IndexError:
            lastpage = 1
        while count<lastpage:
      
            #threads_list = next_page.xpath(bmw.threaddata)
            threads = next_page.xpath(bmw.threads_list)
            tread_data = next_page.xpath(bmw.threaddata)
            for j in tread_data:
                #pass
                threaddata = []
                if j.xpath(bmw.description):
                    threaddata.append(('Description',j.xpath(bmw.description)[0].text_content().encode('utf-8')))
                    #print j.xpath(bmw.description)[0].text_content().encode('utf-8')
                    threaddata.append(('Views', bmw.parse_stats(j.xpath(bmw.stats)[0].text_content())['Views']))
                    threaddata.append(('Views', bmw.parse_stats(j.xpath(bmw.stats)[0].text_content())['Replies']))
#                    print bmw.parse_stats(j.xpath(bmw.stats)[0].text_content())
                    #print j.xpath(bmw.views)[0].text_content()
                    threaddata.append(('Link', j.xpath(bmw.link)[0]))
#                    print j.xpath(bmw.link)[0]
                    mazda3_thread_grab(bmw.thread_id(j.xpath(bmw.link)[0]))
                if not debug:
                    udb.insert_into_table(threaddb, threaddata)
                    #pass
                else:
                    print threaddata
            count += 1
            print count
            print part+addto(ifid,count)
            next_page = xmlTree(part+addto(ifid,count))
    if not debug:
        udb.close()
开发者ID:hackaway,项目名称:forum,代码行数:50,代码来源:mazda3_grabber.py

示例8: priuschat_thread_grab

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import insert_into_table [as 别名]
def priuschat_thread_grab(url, postsdb = 'priuschat_posts',debug = False):
    bimm = priuschat()
    next_page = xmlTree(url)
    #posts = main_page
    if not debug:
        udb = DBManager()
    while True:
        try:
          
          next = next_page.xpath(bimm.next_link)[0]
          print next
                
        except IndexError:
            next = None
        posts = next_page.xpath(bimm.postdata)
        for t in posts:
            if t.xpath(bimm.posterid):
                threaddata = []
                threaddata.append(('TimeOfPost',bimm.convert_to_valid_date(bimm.last_activity(t.xpath(bimm.timeofpost)[0]\
                                                                                              .text_content().strip()))))
                #print t.xpath(bimm.timeofpost)[0].text_content().strip()
                threaddata.append(('PosterID',bimm.poster_id(t.xpath(bimm.posterid)[0])))
                #print bimm.poster_id(t.xpath(bimm.posterid)[0])#[0].text_content()
                threaddata.append(('PostID',bimm.post_id(t.xpath(bimm.postid)[0])))
                #print bimm.post_id(t.xpath(bimm.postid)[0])#[0].text_content()
                try:
                    threaddata.append(('PostCountInThread',t.xpath(bimm.postcount)[0].text_content()))
                    #print t.xpath(bimm.postcount)[0].text_content()
                except AttributeError:
                    threaddata.append(('PostCountInThread',t.xpath(bimm.postcount)[0]))
                    #print t.xpath(bimm.postcount)[0]
                threaddata.append(('Link',t.xpath(bimm.postlink)[0]))
                #print t.xpath(bimm.postlink)#[0].text_content()
                priuschat_user_grab(t.xpath(bimm.posterid)[0],'priuschat_users')
                if not debug:
                    udb.insert_into_table(postsdb, threaddata)
                else:
                    print threaddata
        if next:
                #pdb.set_trace() 
            next_page = xmlTree(next)
            
        elif not next:
            if not debug:
                udb.close()
            break
开发者ID:hackaway,项目名称:forum,代码行数:48,代码来源:priuschat_grabber.py

示例9: mazda3_user_grab

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import insert_into_table [as 别名]
def mazda3_user_grab(url, userdb = 'mazda3_users',debug = True):
    bimm = mazda3()
    main_page = xmlTree_w_login(url, 'mazda', 'somebodyis', 'anybodyanybody')
    userdata = []
    if main_page:
            if not debug:
                udb = DBManager()
            #pdb.set_trace()
            if len(main_page.xpath(bimm.location))>0:
                #print main_page.xpath(bimm.location)[0].text_content().strip()
                userdata.append(('Location', main_page.xpath(bimm.location)[0].text_content().strip()))
            if len(main_page.xpath(bimm.car_make))>0:
                #print main_page.xpath(bimm.cars)[0].text_content()
                userdata.append(('Cars', main_page.xpath(bimm.car_make)[0].text_content()\
                                   +main_page.xpath(bimm.car_year)[0].text_content()))
        #   if len(main_page.xpath(bimm.interests))>0:
        #       #print main_page.xpath(bimm.interests)[0].text_content()
        #       userdata.append(('Interests', main_page.xpath(bimm.interests)[0].text_content()))
            if len(main_page.xpath(bimm.noposts))>0:
                #print bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())
                userdata.append(('TotalPosts', bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())))
            if len(main_page.xpath(bimm.lastac))>0:
                #print bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content())
                userdata.append(('LastActivity', bimm.convert_to_valid_date(bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content()))))
            if len(main_page.xpath(bimm.joindate))>0:
                #print bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content())
                userdata.append(('JoinDate', bimm.convert_to_valid_date(bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content()))))
                #if len(main_page.xpath(bimm.ppday))>0:
                #  print bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())
            #if len(main_page.xpath(bimm.cars))>0:
                #  print main_page.xpath(bimm.cars)[0].text_content()
            if len(main_page.xpath(bimm.handle))>0:
                #print bimm.get_handle(main_page.xpath(bimm.handle)[0].text_content())
                userdata.append(('Handle', bimm.get_handle(main_page.xpath(bimm.handle)[0])))
            if len(main_page.xpath(bimm.minus_fb))>0:
                userdata.append(('NegativeFeedback', main_page.xpath(bimm.minus_fb)[0].text_content().strip()))
            if len(main_page.xpath(bimm.plus_fb))>0:
                userdata.append(('PositiveFeedback', main_page.xpath(bimm.plus_fb)[0].text_content().strip()))
            if not debug:
                udb.insert_into_table(userdb, userdata)
                udb.close()
            else:
                print userdata
    else:
        pass
开发者ID:hackaway,项目名称:forum,代码行数:47,代码来源:mazda3_grabber.py

示例10: bimmerfest_thread_grab

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import insert_into_table [as 别名]
def bimmerfest_thread_grab(url,postsdb='bimmerfest_posts', debug = True):
    #print "ceva"
    bimm = bimmerfest()
    next_page = xmlTree(url)
    #posts = main_page
    if not debug:
        udb = DBManager()
    while True:
        try:
            next = next_page.xpath(bimm.next_link)[0]
        except IndexError:
            next = None
        posts = next_page.xpath(bimm.postdata)
        for t in posts:
            if t.xpath(bimm.posterid):
                threaddata = [] 
                #print '**********************************************************************'
                #print t.xpath(bimm.timeofpost)[0].text_content().strip()
                threaddata.append(('TimeOfPost',bimm.convert_to_valid_date(bimm.last_activity(t.xpath(bimm.timeofpost)[0].text_content().strip()))))
                #print bimm.poster_id(t.xpath(bimm.posterid)[0])#[0].text_content()
                threaddata.append(('PosterID',bimm.poster_id(t.xpath(bimm.posterid)[0])))#[0].text_content()))
                #print bimm.post_id(t.xpath(bimm.postid)[0])#[0].text_content()
                threaddata.append(('PostID',bimm.post_id(t.xpath(bimm.postid)[0])))
                #print t.xpath(bimm.postcount)[0].text_content()
                threaddata.append(('PostCountInThread', t.xpath(bimm.postcount)[0].text_content()))
                #print t.xpath(bimm.postlink)#[0].text_content()
                threaddata.append(('Link',t.xpath(bimm.postlink)[0]))
                threaddata.append(('ThreadID',bimm.thread_id(t.xpath(bimm.post_thread)[0])))
                bimmerfest_user_grab(bimm.domain+t.xpath(bimm.posterid)[0], 'bimmerfest_users')
                if not debug:
                    udb.insert_into_table(postsdb, threaddata)
                else:
                    print threaddata
                #print '**********************************************************************'
        if next:
            next_page = xmlTree(bimm.domain+next+alltime)
            
        elif not next:
            if not debug:
                udb.close()
            else:
                pass
            break
开发者ID:hackaway,项目名称:forum,代码行数:45,代码来源:bimmerfest_grabber.py

示例11: mazda3_thread_grab

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import insert_into_table [as 别名]
def mazda3_thread_grab(url, postsdb = 'mazda3_posts', debug = True):
        bimm = mazda3()
        next_page = xmlTree(url)
        lvl1 = next_page.xpath(bimm.postdata)
        count = 0
        pos = url.find('topic=') + len('topic=')
        part = url[:pos]
        fid = url[pos:]
        ifid = fid.split(r'.')
        if not debug:
            udb = DBManager()
        try:
            lastpage = int(next_page.xpath(bimm.last_page_threads)[0].text_content())
        except IndexError:
                lastpage = 1 
        
        while count<lastpage:
                posts = next_page.xpath(bimm.postdata)
                for pst in posts:
                        threaddata = []
                        threaddata.append(('TimeOfPost',bimm.convert_to_valid_date(bimm.last_activity(bimm.time_of_post(pst.xpath(\
                                                                    bimm.timeofpost)[0].text_content())))))
                        #print bimm.time_of_post(pst.xpath(bimm.timeofpost)[0].text_content())
                        threaddata.append(('PosterID',bimm.poster_id(pst.xpath(bimm.posterid)[0])))
                        #print pst.xpath(bimm.posterid)[0]
                        threaddata.append(('PostID',bimm.post_id(pst.xpath(bimm.postid)[0])))
                        #print pst.xpath(bimm.postid)[0]
                        threaddata.append(('Link',pst.xpath(bimm.postlink)[0]))
                        #print pst.xpath(bimm.postlink)[0]
                        threaddata.append(('PostCountInThread',bimm.post_count(pst.xpath(bimm.postcount)[0].text_content())))
                        threaddata.append(('ThreadID', bimm.thread_id(pst.xpath(bimm.post_thread)[0])))
                        #print bimm.post_count(pst.xpath(bimm.postcount)[0].text_content())
                        mazda3_user_grab(pst.xpath(bimm.posterid)[0],'mazda3_users')
                        if not debug:
                            udb.insert_into_table(postsdb, threaddata)
                        else:
                            print threaddata
                count += 1
                #print count
                #print part+addto(ifid,count)
                next_page = xmlTree(part+addto(ifid,count))
        if not debug:
            udb.close()
开发者ID:hackaway,项目名称:forum,代码行数:45,代码来源:mazda3_grabber.py


注:本文中的DBManager.DBManager.insert_into_table方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。