Exemple #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()
Exemple #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()
Exemple #3
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()
Exemple #4
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()