From da3f9324b6f38e3105ac7bc0129d512c38da9f8b Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Fri, 18 Jan 2019 10:16:23 +0800 Subject: [PATCH] . --- chapter2/init.sql | 8 ++++++++ chapter2/mysite/myapp/models.py | 11 ++++++++++- chapter2/mysite/myapp/templates/myapp/crawl.html | 16 +++------------- chapter2/mysite/myapp/views.py | 5 ++++- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/chapter2/init.sql b/chapter2/init.sql index 92efa8f..fb3465a 100644 --- a/chapter2/init.sql +++ b/chapter2/init.sql @@ -33,4 +33,12 @@ create table platform_infos ( ) comment='平台信息'; +create table news ( +`id` int(11) NOT NULL AUTO_INCREMENT, +comment_time varchar(255) comment '评论时间', +content varchar(1024) comment '评论内容', +comment_id varchar(255) comment '评论ID', + +PRIMARY KEY (`id`) +)comment='最新抓取的20条信息'; diff --git a/chapter2/mysite/myapp/models.py b/chapter2/mysite/myapp/models.py index db96617..05f7df4 100644 --- a/chapter2/mysite/myapp/models.py +++ b/chapter2/mysite/myapp/models.py @@ -27,4 +27,13 @@ class PlatformInfos(models.Model): class Meta: managed = False - db_table = 'platform_infos' \ No newline at end of file + db_table = 'platform_infos' + +class News(models.Model): + comment_time = models.CharField(max_length=255, blank=True, null=True) + content = models.CharField(max_length=1024, blank=True, null=True) + comment_id = models.CharField(max_length=255, blank=True, null=True) + + class Meta: + managed = False + db_table = 'news' \ No newline at end of file diff --git a/chapter2/mysite/myapp/templates/myapp/crawl.html b/chapter2/mysite/myapp/templates/myapp/crawl.html index 00b7ce5..7b1aed6 100644 --- a/chapter2/mysite/myapp/templates/myapp/crawl.html +++ b/chapter2/mysite/myapp/templates/myapp/crawl.html @@ -120,19 +120,9 @@
-