Example #1
0
 def __init__(self):
     handlers = [
         (r"/", HomeHandler),
         (r"/page/(\d+)/?", HomeHandler),
         (r"/category/([^/]+)/?", CategoryHandler),
         (r"/category/([^/]+)/(\d+)?/?", CategoryHandler),
         (r"/search/([^/]+)/?", SearchHandler),
         (r"/search/([^/]+)/(\d+)?/?", SearchHandler),
         (r"/entry/([^/]+)", EntryHandler),
         (r"/feed", FeedHandler),
         (r"/compose", admin.ComposeHandler),
         (r"/admin/list", admin.ListHandler),
         (r"/auth/login", admin.AuthLoginHandler),
         (r"/auth/logout", admin.AuthLogoutHandler),
     ]
     settings = dict(
         blog_title=u"Tornado Blog",
         template_path=os.path.join(os.path.dirname(__file__), "templates"),
         static_path=os.path.join(os.path.dirname(__file__), "static"),
         ui_modules={"Entry": EntryModule},
         xsrf_cookies=True,
         cookie_secret="11oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=",
         login_url="/auth/login",
         autoescape=None,
     )
     tornado.web.Application.__init__(self, handlers, **settings)
     self.db = lemondb.connect("mysql",
                               host="localhost",
                               user="******",
                               passwd="",
                               db="blog",
                               charset="utf8")
Example #2
0
	def __init__(self):
		handlers = [
			(r"/", HomeHandler),
			(r"/page/(\d+)/?", HomeHandler),
			(r"/category/([^/]+)/?", CategoryHandler),
			(r"/category/([^/]+)/(\d+)?/?", CategoryHandler),
			(r"/search/([^/]+)/?", SearchHandler),
			(r"/search/([^/]+)/(\d+)?/?", SearchHandler),
			(r"/entry/([^/]+)", EntryHandler),
			(r"/feed", FeedHandler),
			(r"/compose", admin.ComposeHandler),
			(r"/admin/list", admin.ListHandler),
			(r"/auth/login", admin.AuthLoginHandler),
			(r"/auth/logout", admin.AuthLogoutHandler),
		]
		settings = dict(
			blog_title=u"Tornado Blog",
			template_path=os.path.join(os.path.dirname(__file__), "templates"),
			static_path=os.path.join(os.path.dirname(__file__), "static"),
			ui_modules={"Entry": EntryModule},
			xsrf_cookies=True,
			cookie_secret="11oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=",
			login_url="/auth/login",
			autoescape=None,
		)
		tornado.web.Application.__init__(self, handlers, **settings)
		self.db = lemondb.connect("mysql", host="localhost", user="******", passwd="", db="blog", charset="utf8")
Example #3
0
File: main.py Project: afarfly/blog
    def __init__(self):
        
        settings = dict(
            debug=options.debug,
			autoescape=None,
            xsrf_cookies=True,
            template_path=os.path.join(os.path.dirname(__file__), "templates"),
            static_path=os.path.join(os.path.dirname(__file__), "static"),
            cookie_secret=options.cookie_secret,
            login_url="/auth/login",
        )
        
        import sys
        sys.path.append("dbutil")
        import lemondb
        self.db = lemondb.connect(options.database, **setting_parm.database_types[options.database])
        
        from handlers import handlers
        super(Application, self).__init__(handlers, **settings)
Example #4
0
import requests
import re
import lemondb

if __name__ == "__main__":
    db = lemondb.connect("mysql", host="localhost", user="******", passwd="", db="blog", charset="utf8")
    db2 = lemondb.connect("sqlite", db="e:/sqlite/pyblog.db", charset="utf8")
    contents = db.query("select * from typecho_contents")
    if contents != None:
        for con in contents:
            cid = con.cid
            title = con.title
            slug = con.slug
            created = con.created
            modified = con.modified
            markdown = con.markdown
            html = con.html
            db2.execute(
                "insert into typecho_contents(cid, title, slug, created, modified, markdown, html) values(%s, %s, %s, %s, %s, %s, %s)",
                cid,
                title,
                slug,
                created,
                modified,
                markdown,
                html,
            )
    print "DONE"
Example #5
0
import requests
import re
import lemondb

if __name__ == "__main__":
    db = lemondb.connect("mysql", host="localhost", user="******", passwd="", db="blog", charset="utf8")
    next = 'http://oo.xx/?paged=1'
    if next != None:
        r = requests.get(next)
        html = r.content
        pattern = re.compile(r'<h2 class="entry-title">.*?(http://oo.xx/\?p=\d+).*?</a></h2>', re.S)
        for match in pattern.finditer(html):
            url = match.group(1)
            print url
            id = re.compile(r'http://oo.xx/\?p=(\d+)').search(url).group(1)
            r_url = requests.get(url)
            r_html = r_url.content
            match = re.compile(r'<div class="entry-content">(.*)</div><!-- \.entry-content -->', re.S).search(r_html)
            if match:
                content = match.group(1).strip()
                db.execute("update typecho_contents_new set text = %s where cid = %s", content, id)
                print id+",DONE"
            else:
                print id+",NO"
    print "DONE"