Example #1
0
def download_new(pages=50):
    """
    Download newest 50 pages to update the data base.
    :param pages:
    :return:
    """
    from mysql_database import connect, insert_link, insert_reply
    conn = connect()
    stop = False
    import json
    for i in range(1, pages):
        ids, links = get_page1(str(i))
        if stop: break
        import sys
        sys.stderr.write(str(i) + "\n")
        ids, links = get_page1(str(i))
        for id in ids:
            reply = get_yasuo(id)
            link = get_link(id)
            id, sql, data = parseReply2sql(json.loads(reply))
            rst = insert_reply(conn, id, sql)
            id, sql, data = parseLink2sql(json.loads(link))
            if id is not None:
                insert_link(conn, id, sql)
    conn.close()
Example #2
0
def download_new(pages=50):
    """
    Download newest 50 pages to update the data base.
    :param pages:
    :return:
    """
    from mysql_database import connect, insert_link, insert_reply
    conn = connect()
    stop = False
    import json
    for i in range(1, pages):
        ids, links = get_page1(str(i))
        if stop: break
        import sys
        sys.stderr.write(str(i) + "\n")
        ids, links = get_page1(str(i))
        for id in ids:
            reply = get_yasuo(id)
            link = get_link(id)
            id, sql, data = parseReply2sql(json.loads(reply))
            rst = insert_reply(conn, id, sql)
            id, sql, data = parseLink2sql(json.loads(link))
            if id is not None:
                insert_link(conn, id, sql)
    conn.close()
Example #3
0
def fileReply2sql():
    """
    :return:
    """
    import json
    from mysql_database import connect, insert_reply
    conn = connect()
    with open("reply.json") as REPLY, open("reply.sql", "w") as SQL:
        for line in REPLY:
            id, sql = parseReply2sql(json.loads(line))
            insert_reply(conn, id, sql)
    conn.close()
Example #4
0
def fileReply2sql():
    """
    :return:
    """
    import json
    from mysql_database import connect, insert_reply
    conn = connect()
    with open("reply.json") as REPLY, open("reply.sql", "w") as SQL:
        for line in REPLY:
            id, sql = parseReply2sql(json.loads(line))
            insert_reply(conn, id, sql)
    conn.close()
Example #5
0
def fileLink2sql():
    """
    :return:
    """
    import json
    from mysql_database import connect, insert_link
    conn = connect()
    with open("links.json") as LINKS, open("links.sql", "w") as SQL:
        for line in LINKS:
            id, sql = parseLink2sql(json.loads(line))
            if id:
                insert_link(conn, id, sql)
    conn.close()
Example #6
0
def fileLink2sql():
    """
    :return:
    """
    import json
    from mysql_database import connect, insert_link
    conn = connect()
    with open("links.json") as LINKS, open("links.sql", "w") as SQL:
        for line in LINKS:
            id, sql = parseLink2sql(json.loads(line))
            if id:
                insert_link(conn, id, sql)
    conn.close()