示例#1
0
def fetch_questions_and_answers():
    """Grab all questions/answers from Math.StackExchange and add to our db."""
    func = "/questions"
    params = {
        'pagesize': 100,
        'order': 'asc',
        'sort': 'creation',
        'filter': '!*IXk1kM1CRsCvNX-HctMr3GtJ1.gEYTy9JkKKBvy88x)lhGxe1N.aanvfrdZ)D'
    }
    process_each_page(func, params, \
            lambda x: process_api_questions(x, check_quality=False))
    set_last_updated() 
示例#2
0
def fetch_tags():
    """Grab all tags from Math.StackExchange, and add to our database."""
    con = connect_db()
    cur = con.cursor()

    func = "/tags"
    params = {
        'pagesize': 100,
        'order': 'asc',
        'sort': 'name'
    }
    
    process_each_page(func, params, insert_tags)
示例#3
0
def fetch_recent_questions():
    """Grab recent questions/answers from Math.StackExchange and update DB.

    "Recent" is defined as "since the last update".
    """
    ts = get_last_updated()
    if ts == dt.fromtimestamp(0):
        ts = dt.fromtimestamp(60*60*8)
    func = "/questions"
    params = {
            'pagesize': 100,
            'order': 'desc',
            'fromdate': int(mktime((ts - timedelta(hours=8)).timetuple())),
            'sort': 'activity',
            'filter': '!*IXk1kM1CRsCvNX-HctMr3GtJ1.gEYTy9JkKKBvy88x)lhGxe1N.aanvfrdZ)D'
    }
    process_each_page(func, params, process_api_questions)
    
    set_last_updated()