From 02af1300fe38f4e660cd3a846614bc418b5b0cb5 Mon Sep 17 00:00:00 2001 From: Jiang Lu Date: Sat, 30 Jan 2016 21:05:58 +0800 Subject: [PATCH 1/3] week 3 homework week 3 homework --- .../miaozaiye/week3 hm 2.py" | 127 ++++++++++++++++++ .../miaozaiye/week3 hm1.py" | 26 ++++ 2 files changed, 153 insertions(+) create mode 100644 "week3\345\244\247\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/week3 hm 2.py" create mode 100644 "week3\345\244\247\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/week3 hm1.py" diff --git "a/week3\345\244\247\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/week3 hm 2.py" "b/week3\345\244\247\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/week3 hm 2.py" new file mode 100644 index 0000000..013946c --- /dev/null +++ "b/week3\345\244\247\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/week3 hm 2.py" @@ -0,0 +1,127 @@ +from bs4 import BeautifulSoup +import requests +import pymongo + +client = pymongo.MongoClient('localhost',27017) +shouji = client['shouji'] +shouji_link = shouji['shouji_link'] +shouji_info = shouji['shouji_info'] +shouji_info2 = shouji['shouji_info2'] +shouji_info1 = shouji['shouji_info1'] +shouji_sorted1 = shouji['shouji_sorted1'] + +# 获取所有二手手机有效的链接 +url = '' +shoujilink = [] + +def get_links(url): + i = 1 + #http://bj.ganji.com/shouji/o2/ + while True: + url1 = url+'o'+str(i)+'/' + wb_data = requests.get(url1) + soup = BeautifulSoup(wb_data.text,'lxml') + + # while True: + if soup.find_all('ul','pageLink'): + itemlinks = soup.select('a.ft-tit') + for a in itemlinks: + link = a.get('href') + if 'zhuanzhuan' in link.split('.'): + pass + elif 'click' in link.split('.'): + pass + else: + if link in [a['link'] for a in shouji.shouji_link.find()]: + print ('already exists') + pass + else: + print (link) + shouji.shouji_link.insert_one({'link':link}) + # shouji_link.insert_one({'link':link}) + print (shouji.shouji_link.find().count()) + i = i+1 + else: + pass + + + +print (shouji.shouji_link.find().count()) + +# 获取每个链接对应的商品 价格,成色信息. +def get_info(url): + + #先要判断该链接是否已经解读过 + + + if url in [i['link'] for i in shouji_info.find()]: + + pass + else: + + wb_data = requests.get(url,'utf-8') + soup = BeautifulSoup(wb_data.text,'lxml') + # print (soup) + if soup.find_all('ul','second-det-infor clearfix'): + + price = soup.select('i.f22.fc-orange.f-type')[0].get_text() + status = soup.select('ul.second-det-infor.clearfix > li')[0].get_text() + print ('price: ',price,'status: ',status,url) + shouji_info.insert_one({'price':price,'status':status,'link':url}) + + else: + print ('no status') + pass + + +for url in [i['link'] for i in shouji_link.find()]: + # print (url) + get_info(url) + print (shouji.shouji_info.find().count()) + +# 整理状态表达,统一只用 xx新来表达,整理到数据库 shouji_info1 +for i in shouji_info2.find(): + info = i['status'].split(' ') if len(i['status'].split(' '))>9 else None + if info == None: + pass + else: + info = info[8].split('新')[0]+'新' + #print({'status':info,'price':i['price']}) + shouji.shouji_info1.insert_one({'status':info,'price':i['price']}) + + +# 求出各个状态下的平均值,并储存在新的数据库 shouji_sorted1 里面,用于之后的排序. +pipeline = [ + {'$group':{'_id':'$status','counts':{'$sum':1}}}, + +] + +for i in shouji_info1.aggregate(pipeline): + sum = 0 + for a in shouji_info1.find({'status':i['_id']}): + sum = sum + int(a['price']) + avg = int(sum/i['counts']) + shouji_sorted1.insert_one ({'name':i['_id'],'data':[avg],'type':'line'}) + + +# 将shouji_sorted1 按照平均值从小到大排序,并以此产生,用于之后的表格数据. +def sort(): + pipeline=[{'$sort':{'data':1}}] + + for i in shouji_sorted1.aggregate(pipeline): + yield + + +# 画出线图 +options = { + 'chart' :{'zoomType':'xy'}, + 'title' :{'text':'二手手机成色对均价影响'}, + 'subtitle':{'text':'可视化统计图表'}, + 'xAxis' :{'categories':[i['name'] for i in sort()]}, + 'yAxis' :{'title':{'text':'平均价'}} + } + +series = [i['data'] for i in sort()] + + +charts.plot(series,options=options,show='inline') \ No newline at end of file diff --git "a/week3\345\244\247\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/week3 hm1.py" "b/week3\345\244\247\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/week3 hm1.py" new file mode 100644 index 0000000..20df519 --- /dev/null +++ "b/week3\345\244\247\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/week3 hm1.py" @@ -0,0 +1,26 @@ +import pymongo +import charts +from datetime import timedelta,date + +client = pymongo.MongoClient('localhost',27017) +ganji = client['ganji'] +item_info1 = ganji['item_info1'] + +def get_area_data(area): + pipeline = [ + {'$match':{'area':area}}, + {'$group':{'_id':'$cates','counts':{'$sum':1}}}, + {'$sort':{'counts':-1}}, + {'$limit':4} + ] + + for i in item_info1.aggregate(pipeline): + data = { + 'name':i['_id'], + 'data':[i['counts']], + 'type':'column' + } + yield data + +series = [data for data in get_area_data('朝阳')] +charts.plot(series,show ='inline',options = dict(title = dict(text ='北京二手交易信息'))) \ No newline at end of file From a0ffb9fdaec9d26a37dc06d4b34f17ecb2219445 Mon Sep 17 00:00:00 2001 From: Jiang Lu Date: Fri, 5 Feb 2016 00:04:19 +0800 Subject: [PATCH 2/3] 4.1 homework 4.1 homework --- .../miaozaiye/class4hm/__init__.py" | 0 .../miaozaiye/class4hm/settings.py" | 124 +++++++++++ .../miaozaiye/class4hm/urls.py" | 23 ++ .../miaozaiye/class4hm/wsgi.py" | 16 ++ .../miaozaiye/db.sqlite3" | Bin 0 -> 3072 bytes .../miaozaiye/manage.py" | 10 + .../miaozaiye/purelayoutblog/__init__.py" | 0 .../miaozaiye/purelayoutblog/admin.py" | 3 + .../miaozaiye/purelayoutblog/apps.py" | 5 + .../purelayoutblog/migrations/__init__.py" | 0 .../miaozaiye/purelayoutblog/models.py" | 3 + .../miaozaiye/purelayoutblog/tests.py" | 3 + .../miaozaiye/purelayoutblog/views.py" | 6 + .../static/css/layouts/blog-old-ie.css" | 0 .../miaozaiye/static/css/layouts/blog.css" | 2 +- .../static/img/common/andrew-avatar.png" | Bin .../static/img/common/ericf-avatar.png" | Bin .../static/img/common/reid-avatar.png" | Bin .../static/img/common/tilo-avatar.png" | Bin .../miaozaiye/templates/index.html" | 201 ++++++++++++++++++ 20 files changed, 395 insertions(+), 1 deletion(-) create mode 100644 "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/__init__.py" create mode 100644 "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/settings.py" create mode 100644 "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/urls.py" create mode 100644 "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/wsgi.py" create mode 100644 "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/db.sqlite3" create mode 100755 "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/manage.py" create mode 100644 "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/__init__.py" create mode 100644 "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/admin.py" create mode 100644 "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/apps.py" create mode 100644 "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/migrations/__init__.py" create mode 100644 "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/models.py" create mode 100644 "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/tests.py" create mode 100644 "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/views.py" rename "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/css/layouts/blog-old-ie.css" => "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/css/layouts/blog-old-ie.css" (100%) rename "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/css/layouts/blog.css" => "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/css/layouts/blog.css" (99%) rename "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/img/common/andrew-avatar.png" => "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/img/common/andrew-avatar.png" (100%) rename "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/img/common/ericf-avatar.png" => "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/img/common/ericf-avatar.png" (100%) rename "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/img/common/reid-avatar.png" => "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/img/common/reid-avatar.png" (100%) rename "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/img/common/tilo-avatar.png" => "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/img/common/tilo-avatar.png" (100%) create mode 100644 "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/templates/index.html" diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/__init__.py" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/__init__.py" new file mode 100644 index 0000000..e69de29 diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/settings.py" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/settings.py" new file mode 100644 index 0000000..522cf67 --- /dev/null +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/settings.py" @@ -0,0 +1,124 @@ +""" +Django settings for class4hm project. + +Generated by 'django-admin startproject' using Django 1.9.1. + +For more information on this file, see +https://docs.djangoproject.com/en/1.9/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.9/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'in5!=8d6-8do!6joheqciepe62r$+tg&w=$)j-=kws!_02_+@l' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'purelayoutblog', +] + +MIDDLEWARE_CLASSES = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'class4hm.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(BASE_DIR, 'templates')] + , + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'class4hm.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.9/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/1.9/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.9/howto/static-files/ + +STATIC_URL = '/static/' +STATICFILES_DIRS = (os.path.join(BASE_DIR,"static"),) \ No newline at end of file diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/urls.py" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/urls.py" new file mode 100644 index 0000000..6bcea4b --- /dev/null +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/urls.py" @@ -0,0 +1,23 @@ +"""class4hm URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.9/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url +from django.contrib import admin +from purelayoutblog.views import index + +urlpatterns = [ + url(r'^admin/', admin.site.urls), + url(r'^index/',index), +] diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/wsgi.py" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/wsgi.py" new file mode 100644 index 0000000..97a76f6 --- /dev/null +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/wsgi.py" @@ -0,0 +1,16 @@ +""" +WSGI config for class4hm project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "class4hm.settings") + +application = get_wsgi_application() diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/db.sqlite3" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/db.sqlite3" new file mode 100644 index 0000000000000000000000000000000000000000..b9d314acd01dc5ca021266878904748451f75f42 GIT binary patch literal 3072 zcmWFz^vNtqRY=P(%1ta$FlJz3U}R))P*7lCU|`;40x zsEUc{5(BdekQfD{Awbg*2w-9p*Vbl?EJ;ktNi8nS0VePG;?%;@)VySLF0*rxt7C|( zLWrZ2kE;TjT8+HK+*BQ)PR+(hMs{(1ea5Clu$d`YiFxVy@wu7lMTsSu`FX_{0!%38 zDq+YgDQGBVrYI?7=9Q$Trxq#r`G+X@h5Gm?1O$2dItE25c)La_IEIG!d-?%Q@^$qK z(NR!JEGSS?C`&9#&PXiMFfujOglhvzg4~K*7N|8RGZkoIN@7WBNoH;;T&pH1Z=&RC fn#Rqj;iDli8UlkU1V;1!V2X`Vw~U4WeM0~MK7nft literal 0 HcmV?d00001 diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/manage.py" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/manage.py" new file mode 100755 index 0000000..a710207 --- /dev/null +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/manage.py" @@ -0,0 +1,10 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "class4hm.settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/__init__.py" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/__init__.py" new file mode 100644 index 0000000..e69de29 diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/admin.py" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/admin.py" new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/admin.py" @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/apps.py" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/apps.py" new file mode 100644 index 0000000..c18856a --- /dev/null +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/apps.py" @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class PurelayoutblogConfig(AppConfig): + name = 'purelayoutblog' diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/migrations/__init__.py" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/migrations/__init__.py" new file mode 100644 index 0000000..e69de29 diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/models.py" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/models.py" new file mode 100644 index 0000000..71a8362 --- /dev/null +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/models.py" @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/tests.py" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/tests.py" new file mode 100644 index 0000000..7ce503c --- /dev/null +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/tests.py" @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/views.py" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/views.py" new file mode 100644 index 0000000..38babcb --- /dev/null +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/views.py" @@ -0,0 +1,6 @@ +from django.shortcuts import render + +# Create your views here. + +def index(request): + return render(request,'index.html') \ No newline at end of file diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/css/layouts/blog-old-ie.css" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/css/layouts/blog-old-ie.css" similarity index 100% rename from "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/css/layouts/blog-old-ie.css" rename to "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/css/layouts/blog-old-ie.css" diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/css/layouts/blog.css" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/css/layouts/blog.css" similarity index 99% rename from "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/css/layouts/blog.css" rename to "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/css/layouts/blog.css" index 297939e..7fa3c27 100755 --- "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/css/layouts/blog.css" +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/css/layouts/blog.css" @@ -159,7 +159,7 @@ h3 { @media (min-width: 48em) { .content { padding: 2em 3em 0; - margin-left: 25%; + margin-left: 35%; } .header { diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/img/common/andrew-avatar.png" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/img/common/andrew-avatar.png" similarity index 100% rename from "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/img/common/andrew-avatar.png" rename to "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/img/common/andrew-avatar.png" diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/img/common/ericf-avatar.png" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/img/common/ericf-avatar.png" similarity index 100% rename from "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/img/common/ericf-avatar.png" rename to "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/img/common/ericf-avatar.png" diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/img/common/reid-avatar.png" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/img/common/reid-avatar.png" similarity index 100% rename from "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/img/common/reid-avatar.png" rename to "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/img/common/reid-avatar.png" diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/img/common/tilo-avatar.png" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/img/common/tilo-avatar.png" similarity index 100% rename from "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/pure-layout-blog/img/common/tilo-avatar.png" rename to "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/img/common/tilo-avatar.png" diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/templates/index.html" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/templates/index.html" new file mode 100644 index 0000000..6438e78 --- /dev/null +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/templates/index.html" @@ -0,0 +1,201 @@ + +{% load static %} + + + + + + + + Blog – Layout Examples – Pure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ +
+

Pinned Post

+ + +
+
+ Tilo Mitra's avatar + +

Introducing Pure

+ + +
+ +
+

+ Yesterday at CSSConf, we launched Pure – a new CSS library. Phew! Here are the slides from the presentation. Although it looks pretty minimalist, we’ve been working on Pure for several months. After many iterations, we have released Pure as a set of small, responsive, CSS modules that you can use in every web project. +

+
+
+
+ +
+

Recent Posts

+ +
+
+ Eric Ferraiuolo's avatar + +

Everything You Need to Know About Grunt

+ + +
+ +
+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. +

+
+
+ +
+
+ Reid Burke's avatar + +

Photos from CSSConf and JSConf

+ + +
+ +
+
+
+ + Photo of someone working poolside at a resort + + +
+

CSSConf Photos

+
+
+ +
+ + Photo of the sunset on the beach + + +
+

JSConf Photos

+
+
+
+
+
+ +
+
+ Andrew Wooldridge's avatar + +

YUI 3.10.2 Released

+ + +
+ +
+

+ We are happy to announce the release of YUI 3.10.2! You can find it now on the Yahoo! CDN, download it directly, or pull it in via npm. We’ve also updated the YUI Library website with the latest documentation. +

+
+
+
+ + +
+
+
+ + + + + + + + From f1b4ff3f29253a8a0da399eeae14ca397a302e70 Mon Sep 17 00:00:00 2001 From: Jiang Lu Date: Sat, 6 Feb 2016 22:03:45 +0800 Subject: [PATCH 3/3] 4.2 homework 4.2 homework --- .../miaozaiye/class4hm/settings.py" | 5 +- .../miaozaiye/purelayoutblog/models.py" | 24 +++ .../miaozaiye/purelayoutblog/views.py" | 29 ++- .../miaozaiye/static/css/layouts/blog.css" | 2 +- .../miaozaiye/templates/index.html" | 131 ++++-------- .../miaozaiye/test.py" | 16 ++ .../miaozaiye/class4hm/__init__.py" | 0 .../miaozaiye/class4hm/settings.py" | 127 ++++++++++++ .../miaozaiye/class4hm/urls.py" | 23 +++ .../miaozaiye/class4hm/wsgi.py" | 16 ++ .../miaozaiye/db.sqlite3" | Bin 0 -> 3072 bytes .../miaozaiye/manage.py" | 10 + .../miaozaiye/purelayoutblog/__init__.py" | 0 .../miaozaiye/purelayoutblog/admin.py" | 3 + .../miaozaiye/purelayoutblog/apps.py" | 5 + .../purelayoutblog/migrations/__init__.py" | 0 .../miaozaiye/purelayoutblog/models.py" | 27 +++ .../miaozaiye/purelayoutblog/tests.py" | 3 + .../miaozaiye/purelayoutblog/views.py" | 33 +++ .../static/css/layouts/blog-old-ie.css" | 191 ++++++++++++++++++ .../miaozaiye/static/css/layouts/blog.css" | 175 ++++++++++++++++ .../static/img/common/andrew-avatar.png" | Bin 0 -> 12755 bytes .../static/img/common/ericf-avatar.png" | Bin 0 -> 14135 bytes .../static/img/common/reid-avatar.png" | Bin 0 -> 12274 bytes .../static/img/common/tilo-avatar.png" | Bin 0 -> 13902 bytes .../miaozaiye/templates/index.html" | 138 +++++++++++++ .../miaozaiye/test.py" | 16 ++ .../homework.css" | 133 ------------ .../images/0001.jpg" | Bin 8363 -> 0 bytes .../images/0002.jpg" | Bin 6601 -> 0 bytes .../images/0003.jpg" | Bin 14198 -> 0 bytes .../images/0004.jpg" | Bin 9316 -> 0 bytes .../images/Fire.png" | Bin 16440 -> 0 bytes .../images/bg3-dark.jpg" | Bin 458692 -> 0 bytes .../images/blah.png" | Bin 21551 -> 0 bytes 35 files changed, 874 insertions(+), 233 deletions(-) create mode 100644 "4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/test.py" create mode 100644 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/__init__.py" create mode 100644 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/settings.py" create mode 100644 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/urls.py" create mode 100644 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/wsgi.py" create mode 100644 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/db.sqlite3" create mode 100755 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/manage.py" create mode 100644 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/__init__.py" create mode 100644 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/admin.py" create mode 100644 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/apps.py" create mode 100644 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/migrations/__init__.py" create mode 100644 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/models.py" create mode 100644 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/tests.py" create mode 100644 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/views.py" create mode 100755 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/css/layouts/blog-old-ie.css" create mode 100755 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/css/layouts/blog.css" create mode 100755 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/img/common/andrew-avatar.png" create mode 100755 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/img/common/ericf-avatar.png" create mode 100755 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/img/common/reid-avatar.png" create mode 100755 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/img/common/tilo-avatar.png" create mode 100644 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/templates/index.html" create mode 100644 "4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/test.py" delete mode 100755 "\347\254\254\344\270\200\345\221\250\350\257\276\347\250\213/1.1\350\256\244\350\257\206\347\275\221\351\241\265\347\232\204\346\236\204\346\210\220/1.1\347\273\203\344\271\240\351\242\230\347\255\224\346\241\210/homework.css" delete mode 100755 "\347\254\254\344\270\200\345\221\250\350\257\276\347\250\213/1.1\350\256\244\350\257\206\347\275\221\351\241\265\347\232\204\346\236\204\346\210\220/1.1\347\273\203\344\271\240\351\242\230\347\255\224\346\241\210/images/0001.jpg" delete mode 100755 "\347\254\254\344\270\200\345\221\250\350\257\276\347\250\213/1.1\350\256\244\350\257\206\347\275\221\351\241\265\347\232\204\346\236\204\346\210\220/1.1\347\273\203\344\271\240\351\242\230\347\255\224\346\241\210/images/0002.jpg" delete mode 100755 "\347\254\254\344\270\200\345\221\250\350\257\276\347\250\213/1.1\350\256\244\350\257\206\347\275\221\351\241\265\347\232\204\346\236\204\346\210\220/1.1\347\273\203\344\271\240\351\242\230\347\255\224\346\241\210/images/0003.jpg" delete mode 100755 "\347\254\254\344\270\200\345\221\250\350\257\276\347\250\213/1.1\350\256\244\350\257\206\347\275\221\351\241\265\347\232\204\346\236\204\346\210\220/1.1\347\273\203\344\271\240\351\242\230\347\255\224\346\241\210/images/0004.jpg" delete mode 100755 "\347\254\254\344\270\200\345\221\250\350\257\276\347\250\213/1.1\350\256\244\350\257\206\347\275\221\351\241\265\347\232\204\346\236\204\346\210\220/1.1\347\273\203\344\271\240\351\242\230\347\255\224\346\241\210/images/Fire.png" delete mode 100755 "\347\254\254\344\270\200\345\221\250\350\257\276\347\250\213/1.1\350\256\244\350\257\206\347\275\221\351\241\265\347\232\204\346\236\204\346\210\220/1.1\347\273\203\344\271\240\351\242\230\347\255\224\346\241\210/images/bg3-dark.jpg" delete mode 100755 "\347\254\254\344\270\200\345\221\250\350\257\276\347\250\213/1.1\350\256\244\350\257\206\347\275\221\351\241\265\347\232\204\346\236\204\346\210\220/1.1\347\273\203\344\271\240\351\242\230\347\255\224\346\241\210/images/blah.png" diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/settings.py" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/settings.py" index 522cf67..0ce9d74 100644 --- "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/settings.py" +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/settings.py" @@ -121,4 +121,7 @@ # https://docs.djangoproject.com/en/1.9/howto/static-files/ STATIC_URL = '/static/' -STATICFILES_DIRS = (os.path.join(BASE_DIR,"static"),) \ No newline at end of file +STATICFILES_DIRS = (os.path.join(BASE_DIR,"static"),) + +from mongoengine import connect +connect('ganji',host='127.0.0.1',port = 27017) \ No newline at end of file diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/models.py" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/models.py" index 71a8362..3e0f132 100644 --- "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/models.py" +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/models.py" @@ -1,3 +1,27 @@ from django.db import models +from mongoengine import * +from mongoengine import connect +import pymongo +# client = pymongo.MongoClient('localhost',27017) +# +# ganji = client['ganji'] +# item_info1 = ganji['item_info1'] + +connect('ganji',host='127.0.0.1',port=27017) + +class ItemInfo(Document): + title = StringField() + area = StringField() + url = StringField() + look = StringField() + price = StringField() + cates = StringField() + pub_date = StringField() + + meta={'collection':'item_info1'} + +# for i in ItemInfo.objects: +# print(i.title,i.area,i.url,i.look) # Create your models here. + diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/views.py" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/views.py" index 38babcb..0212807 100644 --- "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/views.py" +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/views.py" @@ -1,6 +1,33 @@ from django.shortcuts import render +from purelayoutblog.models import ItemInfo +from django.core.paginator import Paginator # Create your views here. def index(request): - return render(request,'index.html') \ No newline at end of file + limit = 10 + item_info = ItemInfo.objects[:20] + paginator = Paginator(item_info,limit) + page = request.GET.get('page',1) + print(request) + print(request.GET) + + + loaded = paginator.page(page) + + + context = { + # 'title':item_info[0].title, + # 'area' :item_info[0].area + # 'area' :'海淀区', + # 'title' :'测试一下' + 'ItemInfo':loaded + + + } + + # print (context) + + + return render(request,'index.html',context) + diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/css/layouts/blog.css" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/css/layouts/blog.css" index 7fa3c27..297939e 100755 --- "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/css/layouts/blog.css" +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/static/css/layouts/blog.css" @@ -159,7 +159,7 @@ h3 { @media (min-width: 48em) { .content { padding: 2em 3em 0; - margin-left: 35%; + margin-left: 25%; } .header { diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/templates/index.html" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/templates/index.html" index 6438e78..e495b44 100644 --- "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/templates/index.html" +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/templates/index.html" @@ -57,8 +57,8 @@