摘要:
记下来,省得每次google过滤器,变量的显示形式的改变一、形式:小写{{ name | lower }} 二、串联:先转义文本到HTML,再转换每行到 <p> 标签{{ my_text|escape|linebreaks }} 三、过滤器的参数显示前30个字{{ bio | truncatewor
阅读全文
posted @ 2018-11-11 19:44
CrossPython
阅读(1607)
推荐(0)
摘要:
当时想做一个多条件查询,但是对于要查询的信息,是分布在不同的表里,这就涉及到了多表查询问题。 DjangoBook里提到了一些查询的方式,但是不够全面,就去百度搜了下。 当去网上百度搜多表查询,或多条件查询时,都能搜到,但是相对较综合点的信息,还是比较少。但是为了实现功能, 也思考了不少。下面贴上一
阅读全文
posted @ 2018-11-08 21:46
CrossPython
阅读(1424)
推荐(0)
摘要:
null 不设置时默认设置为False。设置为True时,数据库表字段中将存入NULL的记录。 null和blank组合使用,null=True,blank=True,表示该字段可以为空 blank 默认设置为False。设置为True时,表字段许可无任何输入。设置为False 时,表字段为必须输入
阅读全文
posted @ 2018-11-08 21:05
CrossPython
阅读(3092)
推荐(0)
摘要:
yum install nodejs
阅读全文
posted @ 2018-11-04 21:47
CrossPython
阅读(424)
推荐(0)
摘要:
import os, sys import django BASE_DIR = os.path.dirname(os.path.abspath(__file__)) # 定位到你的django根目录 sys.path.append(os.path.abspath(os.path.join(BASE_DIR, os.pardir))) os.environ.setdefault("DJANGO_...
阅读全文
posted @ 2018-11-04 19:29
CrossPython
阅读(204)
推荐(0)
摘要:
分 时 日 月 周 命令(最好用绝对路径)比如: * * * * * rm -fr /mnt/* //每分钟执行一次对/mnt目录下文件的删除*/2 * * * * rm -fr /mnt/* //每隔两分钟执行一次*/2 08-17 1,15 3-5 3 rm -fr /mnt/* //在3-5月
阅读全文
posted @ 2018-11-04 18:57
CrossPython
阅读(419)
推荐(0)
摘要:
https://blog.csdn.net/pipisorry/article/details/47905781
阅读全文
posted @ 2018-11-02 12:39
CrossPython
阅读(385)
推荐(0)
摘要:
https://blog.csdn.net/liuweiyuxiang/article/details/71104613 def search(request): searchtype = request.POST.get("searchtype") keyword = request.POST.g
阅读全文
posted @ 2018-10-31 23:24
CrossPython
阅读(633)
推荐(0)
摘要:
result = session.execute('insert into ***') session.commit() last_insert_id = result.lastrowid 注意:如果存在多个用户操作数据库,应保持每个用户或者每个请求线程拥有各自隔离的session https://
阅读全文
posted @ 2018-10-31 23:14
CrossPython
阅读(2694)
推荐(0)
摘要:
models execute via view:
阅读全文
posted @ 2018-10-31 22:52
CrossPython
阅读(1199)
推荐(0)
摘要:
gg:命令将光标移动到文档开头G:命令将光标移动到文档末尾 vi编辑器中在命令行模式下输入G可以直接跳转到页面的底部 在命令行模式下输入1G可以跳转到页面的头部位置 更多在vi中移动编辑位置的命令说明如下: h Move left j Move down k Move up l Move right
阅读全文
posted @ 2018-10-31 16:36
CrossPython
阅读(5983)
推荐(0)
摘要:
centos7中的防火墙改成了firewall,使用iptables无作用,开放端口的方法如下: firewall-cmd --zone=public --add-port=80/tcp --permanent 返回success为成功 命令含义: --zone #作用域 --add-port=80
阅读全文
posted @ 2018-10-31 10:11
CrossPython
阅读(497)
推荐(0)
摘要:
https://blog.csdn.net/yingshukun/article/details/53470424 https://my.oschina.net/auo/blog/222202
阅读全文
posted @ 2018-10-31 09:26
CrossPython
阅读(372)
推荐(0)
摘要:
https://github.com/bukuai/Text-Translation-API-V3-Python https://docs.microsoft.com/zh-cn/azure/cognitive-services/translator/quickstart-python-transl
阅读全文
posted @ 2018-10-31 09:23
CrossPython
阅读(334)
推荐(0)
摘要:
https://blog.csdn.net/yingshukun/article/details/53470424 Google翻译实现
阅读全文
posted @ 2018-10-31 08:37
CrossPython
阅读(257)
推荐(0)
摘要:
前言:最近在公司做爬虫相关的工作,做过数据抓取的都知道,写程序抓取数据的过程并不像平常我们用浏览器打开网页那么简单!大多数的网站为了自己站点的性能和数据安全都设置了各种反爬策略。最常见的就是添加验证码,需要用户登陆,单个IP有次数和频率限制等等!所以广大的爬虫工程师在抓取数据之前都要先调研一下这个网
阅读全文
posted @ 2018-10-30 20:45
CrossPython
阅读(6514)
推荐(0)
摘要:
django, nginx, uwsgi mysite.xml another one.same nginx.conf site1, and 2, 1.conf, 2.conf
阅读全文
posted @ 2018-10-30 20:33
CrossPython
阅读(246)
推荐(0)
摘要:
update user set authentication_string = password('new password'),password_expired = 'N', password_last_changed = now() where user = 'root';
阅读全文
posted @ 2018-10-30 20:17
CrossPython
阅读(205)
推荐(0)
摘要:
dict() to_dict() from django.forms.models import model_to_dict u_dict = model_to_dict(u) last_login django datetime:
阅读全文
posted @ 2018-10-29 21:45
CrossPython
阅读(251)
推荐(0)
摘要:
前言在爬取某些网页时,登陆界面时经常遇到的一个坎,而现在大多数的网站在登陆时都会要求用户填写验证码。当然,我们可以设计一套机器学习的算法去破解验证码,然而,验证码的形式多种多样,稍微变一下(有些甚至是手机短信验证),整套算法可能就完全无效了,所以去强行破解验证码是一个吃力不讨好的活。本文会以知乎网站
阅读全文
posted @ 2018-10-28 19:24
CrossPython
阅读(828)
推荐(0)
摘要:
利用django开发web应用, 我们经常需要进行URL重定向,有时候还需要给URL传递额外的参数。比如用户添加文章完成后需要转到文章列表或某篇文章详情。因此熟练掌握HttpResponseDirect, redirect和reverse这三种方法对于Django Web开发是至关重要。今天小编我就
阅读全文
posted @ 2018-10-28 13:38
CrossPython
阅读(2145)
推荐(0)
摘要:
def logout(request): request.session.flush() return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/')) class LoginView(View): def get(self,request): request.session['log...
阅读全文
posted @ 2018-10-28 12:50
CrossPython
阅读(2466)
推荐(0)
摘要:
先 django 定好sql框架 再 sqlalchemy 根据框架写。。。
阅读全文
posted @ 2018-10-28 12:46
CrossPython
阅读(147)
推荐(0)
摘要:
TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { ...
阅读全文
posted @ 2018-10-28 12:35
CrossPython
阅读(147)
推荐(0)
posted @ 2018-10-28 09:45
CrossPython
阅读(905)
推荐(0)
摘要:
装饰器作用 decorator是当今最流行的设计模式之一,很多使用它的人并不知道它是一种设计模式。这种模式有什么特别之处? 有兴趣可以看看Python Wiki上例子,使用它可以很方便地修改对象行为,通过使用类似例中的接口将修改动作封装在装饰对象中。 decorator 可以动态地修改函数、方法或类
阅读全文
posted @ 2018-10-27 21:11
CrossPython
阅读(762)
推荐(0)
posted @ 2018-10-27 12:35
CrossPython
阅读(979)
推荐(0)
摘要:
# -*- coding: utf-8 -*- from sqlalchemy import create_engine, Column, String, Integer, ForeignKey, Table,Text from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessio...
阅读全文
posted @ 2018-10-27 10:48
CrossPython
阅读(192)
推荐(0)
摘要:
scrapy中有个自带的pipeline工具,ImagesPipeline,可以专门用来储存图片到本地。 但默认储存地址无法配置,所以我们需要写一个自己的pipeline用于储存图片。 先分析一下我们的需求: 1.修改图片路径,路径根据采集到的item中的数据变化; 2.将数据库中保存图片的url更
阅读全文
posted @ 2018-10-26 21:36
CrossPython
阅读(1316)
推荐(0)
摘要:
https://www.jianshu.com/p/d1bb28cbb6a8 scrapy中负责下载文件的是class MyFilesPipeline(FilesPipeline)类 其中负责下载文件的方法是 我们可以很清楚地看到 因为是下载的是文件,所以默认的response参数是为None的,因
阅读全文
posted @ 2018-10-26 21:25
CrossPython
阅读(1960)
推荐(0)
摘要:
hashlib.sha1(to_bytes(url)).hexdigest() hashlib.sha1(to_bytes(url)).hexdigest() MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
阅读全文
posted @ 2018-10-26 19:55
CrossPython
阅读(180)
推荐(0)
摘要:
官方的: https://doc.scrapy.org/en/latest/topics/media-pipeline.html?highlight=item_complete#scrapy.pipelines.images.ImagesPipeline.item_completed https:/
阅读全文
posted @ 2018-10-26 19:10
CrossPython
阅读(278)
推荐(0)
摘要:
需求分析需求:爬取斗鱼主播图片,并下载到本地 思路: 使用Fiddler抓包工具,抓取斗鱼手机APP中的接口使用Scrapy框架的ImagesPipeline实现图片下载ImagesPipeline实现图片下载的使用方法: 在items中的XxxItem中定义 image_urls 和 images
阅读全文
posted @ 2018-10-26 15:16
CrossPython
阅读(1106)
推荐(1)
摘要:
1 # coding:utf-8 2 3 class TidyText(object): 4 def __init__(self,string='',begin='',last=''): 5 super(TidyText,self).__init__() 6 self.result=string 7 self....
阅读全文
posted @ 2018-10-26 08:57
CrossPython
阅读(173)
推荐(0)
摘要:
Scrapy生成的调试信息非常有用,但是通常太啰嗦,你可以在Scrapy项目中的setting.py中设置日志显示等级: LOG_LEVEL = 'ERROR' 日志级别 Scrapy日志有五种等级,按照范围递增顺序排列如下:(注意《Python网络数据采集》书中这里有错) CRITICAL - 严
阅读全文
posted @ 2018-10-25 21:34
CrossPython
阅读(3181)
推荐(0)
摘要:
# coding:utf-8 from sqlalchemy import create_engine, Column, String, Integer, ForeignKey, Table from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker, relati...
阅读全文
posted @ 2018-10-25 20:55
CrossPython
阅读(761)
推荐(0)
摘要:
# -*- coding: utf-8 -*- from sqlalchemy import Column, String, create_engine,ForeignKey,Text,Integer,Table from sqlalchemy.orm import sessionmaker,relationship from sqlalchemy.ext.declarative import...
阅读全文
posted @ 2018-10-25 18:42
CrossPython
阅读(248)
推荐(0)
摘要:
https://blog.csdn.net/pushiqiang/article/details/50652080?utm_source=blogxgwz1 https://blog.csdn.net/qq_40157234/article/details/80691348 https://blog
阅读全文
posted @ 2018-10-25 14:54
CrossPython
阅读(1309)
推荐(0)
摘要:
from django.shortcuts import render,HttpResponse from django.views import View from Fiskars.models import * from django.conf import settings from Fiskars.forms import * import os import xlrd class I...
阅读全文
posted @ 2018-10-25 11:26
CrossPython
阅读(373)
推荐(0)
摘要:
https://blog.csdn.net/xxm524/article/details/48369623
阅读全文
posted @ 2018-10-25 08:49
CrossPython
阅读(794)
推荐(0)