コード例 #1
0
def m_source_modal(sid):
    source = BookSource.get(sid)
    if request.method == 'POST':
        bid = request.form.get('bid')
        ssite = request.form.get('ssite')
        surl = request.form.get('surl')
        source.update(bid, ssite, surl)
        return redirect(request.referrer)
    return render_template('admin/source_modal.html', **locals())
コード例 #2
0
def m_source_delete():
    sid = request.form.get('sid')
    BookSource.delete(sid)
    return redirect(request.referrer)
コード例 #3
0
ファイル: update_book_source.py プロジェクト: amumu/wyzq
# coding : utf8

import os
os.sys.path.append(os.getcwd())

from pymongo import MongoClient

from models import BookSource, Book


MONGO_DBS = ['xiaoshuo', 'xiaoshuo1', 'xiaoshuo2', 'xiaoshuo3', 'xiaoshuo4']
client = MongoClient('localhost', 27017)

source_site = 'hao123.se'
base_url = 'http://www.hao123.se/%s/'


all_books = Book.gets()

for book in all_books:
    title = book.title
    bid = book.id
    for db in MONGO_DBS:
        book_table = client[db].Book
        book_in_mongo = book_table.find_one({"title": title})
        if book_in_mongo:
            source_url = base_url % book_in_mongo.get('bid')
            BookSource.add(bid, source_site, source_url)
        else:
            continue