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..0ce9d74 --- /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,127 @@ +""" +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"),) + +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/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 0000000..b9d314a Binary files /dev/null and "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/db.sqlite3" differ 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..3e0f132 --- /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,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/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..0212807 --- /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,33 @@ +from django.shortcuts import render +from purelayoutblog.models import ItemInfo +from django.core.paginator import Paginator + +# Create your views here. + +def index(request): + 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/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 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.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" 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..e495b44 --- /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,138 @@ + +{% load static %} + + + + + + + + Blog – Layout Examples – Pure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+

Pinned Post

+ + + + {% for item in ItemInfo %} +
+
+ Tilo Mitra's avatar + +

{{ item.title }}

+ + +
+ +
+

+ 发布时间:{{ item.pub_date }}, + 发布价格:{{ item.price }}元 +

+
+
+ {% endfor %} + +
+ {% if ItemInfo.has_previous %} + < pre + {% endif %} + {{ ItemInfo.number }} of {{ ItemInfo.paginator.num_pages }} + {% if ItemInfo.has_next %} + next> + {% endif %} +
+
+ + + + +
+
+
+ + + + + + + + diff --git "a/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/test.py" "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/test.py" new file mode 100644 index 0000000..858314a --- /dev/null +++ "b/4.1\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/test.py" @@ -0,0 +1,16 @@ +import pymongo + +client = pymongo.MongoClient('localhost',27017) + +ganji = client['ganji'] +item_info1 = ganji['item_info1'] + +for item in item_info1.find().limit(100): + print (item) + + +''' +{'_id': ObjectId('5698f528a98063dbe5e91caa'), 'cates': '北京二手家电', 'area': '海淀', 'url': 'http://bj.58.com/jiadian/24494100687030x.shtml', 'pub_date': '2015.12.29', 'price': '1300 元', 'look': '-', 'title': '【图】个人转让西门子带烘干功能滚筒洗衣机 - 海淀知春路二手家电 - 北京58同城'} +{'_id': ObjectId('5698f528a98063dbe4e91cab'), 'cates': '北京二手家电', 'area': '朝阳', 'url': 'http://bj.58.com/jiadian/24636743250110x.shtml', 'pub_date': '2016.01.14', 'price': '600 元', 'look': '-', 'title': '腾房转套时尚床,沙发,衣柜, 一级节能冰箱 滚筒洗衣机 海尔电热水器,液晶电视 - 朝阳太阳宫二手家电 - 北京58同城'} + +''' \ No newline at end of file diff --git "a/4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/__init__.py" "b/4.2\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.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/settings.py" "b/4.2\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..0ce9d74 --- /dev/null +++ "b/4.2\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,127 @@ +""" +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"),) + +from mongoengine import connect +connect('ganji',host='127.0.0.1',port = 27017) \ No newline at end of file diff --git "a/4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/urls.py" "b/4.2\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.2\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.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/class4hm/wsgi.py" "b/4.2\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.2\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.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/db.sqlite3" "b/4.2\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 0000000..b9d314a Binary files /dev/null and "b/4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/db.sqlite3" differ diff --git "a/4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/manage.py" "b/4.2\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.2\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.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/__init__.py" "b/4.2\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.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/admin.py" "b/4.2\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.2\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.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/apps.py" "b/4.2\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.2\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.2\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.2\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.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/models.py" "b/4.2\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..3e0f132 --- /dev/null +++ "b/4.2\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,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.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/tests.py" "b/4.2\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.2\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.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/purelayoutblog/views.py" "b/4.2\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..0212807 --- /dev/null +++ "b/4.2\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,33 @@ +from django.shortcuts import render +from purelayoutblog.models import ItemInfo +from django.core.paginator import Paginator + +# Create your views here. + +def index(request): + 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.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" "b/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" new file mode 100755 index 0000000..73ef458 --- /dev/null +++ "b/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" @@ -0,0 +1,191 @@ +* { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +a { + text-decoration: none; + color: rgb(61, 146, 201); +} + +a:hover, +a:focus { + text-decoration: underline; +} + +h3 { + font-weight: 100; +} + +/* LAYOUT CSS */ + +.pure-img-responsive { + max-width: 100%; + height: auto; +} + +#layout { + padding: 0; +} + +.header { + text-align: center; + top: auto; + margin: 3em auto; +} + +.sidebar { + background: rgb(61, 79, 93); + color: #fff; +} + +.brand-title, +.brand-tagline { + margin: 0; +} + +.brand-title { + text-transform: uppercase; +} + +.brand-tagline { + font-weight: 300; + color: rgb(176, 202, 219); +} + +.nav-list { + margin: 0; + padding: 0; + list-style: none; +} + +.nav-item { + display: inline-block; + *display: inline; + zoom: 1; +} + +.nav-item a { + background: transparent; + border: 2px solid rgb(176, 202, 219); + color: #fff; + margin-top: 1em; + letter-spacing: 0.05em; + text-transform: uppercase; + font-size: 85%; +} + +.nav-item a:hover, +.nav-item a:focus { + border: 2px solid rgb(61, 146, 201); + text-decoration: none; +} + +.content-subhead { + text-transform: uppercase; + color: #aaa; + border-bottom: 1px solid #eee; + padding: 0.4em 0; + font-size: 80%; + font-weight: 500; + letter-spacing: 0.1em; +} + +.content { + padding: 2em 1em 0; +} + +.post { + padding-bottom: 2em; +} + +.post-title { + font-size: 2em; + color: #222; + margin-bottom: 0.2em; +} + +.post-avatar { + border-radius: 50px; + float: right; + margin-left: 1em; +} + +.post-description { + font-family: Georgia, "Cambria", serif; + color: #444; + line-height: 1.8em; +} + +.post-meta { + color: #999; + font-size: 90%; + margin: 0; +} + +.post-category { + margin: 0 0.1em; + padding: 0.3em 1em; + color: #fff; + background: #999; + font-size: 80%; +} + +.post-category-design { + background: #5aba59; +} + +.post-category-pure { + background: #4d85d1; +} + +.post-category-yui { + background: #8156a7; +} + +.post-category-js { + background: #df2d4f; +} + +.post-images { + margin: 1em 0; +} + +.post-image-meta { + margin-top: -3.5em; + margin-left: 1em; + color: #fff; + text-shadow: 0 1px 1px #333; +} + +.footer { + text-align: center; + padding: 1em 0; +} + +.footer a { + color: #ccc; + font-size: 80%; +} + +.footer .pure-menu a:hover, +.footer .pure-menu a:focus { + background: none; +} + +.content { + padding: 2em 3em 0; + margin-left: 25%; +} + +.header { + margin: 80% 2em 0; + text-align: right; +} + +.sidebar { + position: fixed; + top: 0; + bottom: 0; +} \ No newline at end of file diff --git "a/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" "b/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" new file mode 100755 index 0000000..297939e --- /dev/null +++ "b/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" @@ -0,0 +1,175 @@ +* { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +a { + text-decoration: none; + color: rgb(61, 146, 201); +} +a:hover, +a:focus { + text-decoration: underline; +} + +h3 { + font-weight: 100; +} + +/* LAYOUT CSS */ +.pure-img-responsive { + max-width: 100%; + height: auto; +} + +#layout { + padding: 0; +} + +.header { + text-align: center; + top: auto; + margin: 3em auto; +} + +.sidebar { + background: rgb(61, 79, 93); + color: #fff; +} + +.brand-title, +.brand-tagline { + margin: 0; +} +.brand-title { + text-transform: uppercase; +} +.brand-tagline { + font-weight: 300; + color: rgb(176, 202, 219); +} + +.nav-list { + margin: 0; + padding: 0; + list-style: none; +} +.nav-item { + display: inline-block; + *display: inline; + zoom: 1; +} +.nav-item a { + background: transparent; + border: 2px solid rgb(176, 202, 219); + color: #fff; + margin-top: 1em; + letter-spacing: 0.05em; + text-transform: uppercase; + font-size: 85%; +} +.nav-item a:hover, +.nav-item a:focus { + border: 2px solid rgb(61, 146, 201); + text-decoration: none; +} + +.content-subhead { + text-transform: uppercase; + color: #aaa; + border-bottom: 1px solid #eee; + padding: 0.4em 0; + font-size: 80%; + font-weight: 500; + letter-spacing: 0.1em; +} + +.content { + padding: 2em 1em 0; +} + +.post { + padding-bottom: 2em; +} +.post-title { + font-size: 2em; + color: #222; + margin-bottom: 0.2em; +} +.post-avatar { + border-radius: 50px; + float: right; + margin-left: 1em; +} +.post-description { + font-family: Georgia, "Cambria", serif; + color: #444; + line-height: 1.8em; +} +.post-meta { + color: #999; + font-size: 90%; + margin: 0; +} + +.post-category { + margin: 0 0.1em; + padding: 0.3em 1em; + color: #fff; + background: #999; + font-size: 80%; +} + .post-category-design { + background: #5aba59; + } + .post-category-pure { + background: #4d85d1; + } + .post-category-yui { + background: #8156a7; + } + .post-category-js { + background: #df2d4f; + } + +.post-images { + margin: 1em 0; +} +.post-image-meta { + margin-top: -3.5em; + margin-left: 1em; + color: #fff; + text-shadow: 0 1px 1px #333; +} + +.footer { + text-align: center; + padding: 1em 0; +} +.footer a { + color: #ccc; + font-size: 80%; +} +.footer .pure-menu a:hover, +.footer .pure-menu a:focus { + background: none; +} + +@media (min-width: 48em) { + .content { + padding: 2em 3em 0; + margin-left: 25%; + } + + .header { + margin: 80% 2em 0; + text-align: right; + } + + .sidebar { + position: fixed; + top: 0; + bottom: 0; + } +} diff --git "a/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" "b/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" new file mode 100755 index 0000000..409bde0 Binary files /dev/null and "b/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" differ diff --git "a/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" "b/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" new file mode 100755 index 0000000..40983a1 Binary files /dev/null and "b/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" differ diff --git "a/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" "b/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" new file mode 100755 index 0000000..1b3615e Binary files /dev/null and "b/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" differ diff --git "a/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" "b/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" new file mode 100755 index 0000000..f3c0977 Binary files /dev/null and "b/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" differ diff --git "a/4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/templates/index.html" "b/4.2\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..e495b44 --- /dev/null +++ "b/4.2\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,138 @@ + +{% load static %} + + + + + + + + Blog – Layout Examples – Pure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + +
+

Pinned Post

+ + + + {% for item in ItemInfo %} +
+
+ Tilo Mitra's avatar + +

{{ item.title }}

+ + +
+ +
+

+ 发布时间:{{ item.pub_date }}, + 发布价格:{{ item.price }}元 +

+
+
+ {% endfor %} + +
+ {% if ItemInfo.has_previous %} + < pre + {% endif %} + {{ ItemInfo.number }} of {{ ItemInfo.paginator.num_pages }} + {% if ItemInfo.has_next %} + next> + {% endif %} +
+
+ + + + +
+
+
+ + + + + + + + diff --git "a/4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/test.py" "b/4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/test.py" new file mode 100644 index 0000000..858314a --- /dev/null +++ "b/4.2\347\273\203\344\271\240\344\275\234\344\270\232\346\217\220\344\272\244/miaozaiye/test.py" @@ -0,0 +1,16 @@ +import pymongo + +client = pymongo.MongoClient('localhost',27017) + +ganji = client['ganji'] +item_info1 = ganji['item_info1'] + +for item in item_info1.find().limit(100): + print (item) + + +''' +{'_id': ObjectId('5698f528a98063dbe5e91caa'), 'cates': '北京二手家电', 'area': '海淀', 'url': 'http://bj.58.com/jiadian/24494100687030x.shtml', 'pub_date': '2015.12.29', 'price': '1300 元', 'look': '-', 'title': '【图】个人转让西门子带烘干功能滚筒洗衣机 - 海淀知春路二手家电 - 北京58同城'} +{'_id': ObjectId('5698f528a98063dbe4e91cab'), 'cates': '北京二手家电', 'area': '朝阳', 'url': 'http://bj.58.com/jiadian/24636743250110x.shtml', 'pub_date': '2016.01.14', 'price': '600 元', 'look': '-', 'title': '腾房转套时尚床,沙发,衣柜, 一级节能冰箱 滚筒洗衣机 海尔电热水器,液晶电视 - 朝阳太阳宫二手家电 - 北京58同城'} + +''' \ 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 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 diff --git "a/\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" "b/\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" deleted file mode 100755 index e81cd25..0000000 --- "a/\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" +++ /dev/null @@ -1,133 +0,0 @@ -body { - padding: 0 0 0 0; - background-color: #ffffff; - background-image: url(images/bg3-dark.jpg); - background-position: top left; - background-repeat: no-repeat; - background-size: cover; - font-family: Helvetica, Arial, sans-serif; -} -.nav { - padding-left: 0; - margin: 5px 0 20px 0; - text-align: center; -} -.nav li { - display: inline; - padding-right: 10px; -} -.nav li:last-child { - padding-right: 0; -} -.header { - padding: 10px 10px 10px 10px; - -} - -.header a { - color: #ffffff; -} -.header img { - display: block; - margin: 0 auto 0 auto; -} -.header h1 { - text-align: center; -} - -.main-content { - width: 500px; - padding: 20px 20px 20px 20px; - border: 1px solid #dddddd; - border-radius:15px; - margin: 30px auto 0 auto; - background: #fdffff; - -webkit-box-shadow: 0 0 22px 0 rgba(50, 50, 50, 1); - -moz-box-shadow: 0 0 22px 0 rgba(50, 50, 50, 1); - box-shadow: 0 0 22px 0 rgba(50, 50, 50, 1); - -} -h1, h2, h3 { - color: #37A5F0; -} -h1 { - color: #ffffff; - margin: 10px 0 15px 0; - text-align: center; -} -h2 { - margin: 10px 0 20px 0; - text-align: center; - font-size: 26px; - font-weight: bold; -} -h3 { - margin: 15px 0 15px 0; - border-bottom: 1px solid #CCCCCC; - padding-bottom: 3px; - font-size: 18px; - font-weight: bold; -} -ul { - padding: 0 0 0 50px; -} -ul li { - margin: 0 0 5px 0; -} -ol { - padding: 0 0 0 50px; -} - -p { - color: #505050; - font-size: 15px; - padding-left: 10px; - padding-right: 10px; -} -hr { - border:none; - border-top:1px solid gainsboro; - height:0; -} - -.main-content { - width: 500px; - padding: 20px 20px 20px 20px; - border: 1px solid #dddddd; - margin: 30px auto 0 auto; - background: #ffffff url(images/crossword.png) top left repeat; -} -.main-content p { - line-height: 26px; -} -.photos { - list-style-type: none; - padding: 0; -} -.photos li { - display: inline; - padding-left: 11px; -} -.featured-image { - width: 500px; - height: 195px; - background: #ffffff url(images/featured-cake.png) top left no-repeat; -} -.featured-image h3 { - margin: 0; - background-color: #333333; - color: #ffffff; - padding: 5px 0 5px 15px; - text-transform: uppercase; -} -.footer { - margin-top: 20px; -} -.footer p { - color: #aaaaaa; - text-align: center; - font-weight: bold; - font-size: 12px; - font-style: italic; - text-transform: uppercase; -} diff --git "a/\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" "b/\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" deleted file mode 100755 index 44759be..0000000 Binary files "a/\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" and /dev/null differ diff --git "a/\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" "b/\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" deleted file mode 100755 index 18a7b60..0000000 Binary files "a/\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" and /dev/null differ diff --git "a/\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" "b/\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" deleted file mode 100755 index 9766ca0..0000000 Binary files "a/\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" and /dev/null differ diff --git "a/\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" "b/\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" deleted file mode 100755 index d52a637..0000000 Binary files "a/\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" and /dev/null differ diff --git "a/\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" "b/\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" deleted file mode 100755 index 9bc9ddb..0000000 Binary files "a/\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" and /dev/null differ diff --git "a/\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" "b/\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" deleted file mode 100755 index b3dc124..0000000 Binary files "a/\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" and /dev/null differ diff --git "a/\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" "b/\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" deleted file mode 100755 index 660c0ea..0000000 Binary files "a/\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" and /dev/null differ