摘要: https://linux.cn/article-8051-1.html 阅读全文
posted @ 2018-11-24 19:57 CrossPython 阅读(137) 评论(0) 推荐(0) 编辑
摘要: https://blog.csdn.net/qq_29349715/article/details/79730786 python协程只能运行在事件循环中,但是一旦事件循环运行,又会阻塞当前任务。所以只能在当前进程中再开一个线程,这个线程的主要任务是运行事件循环,就是event_loop,因为他是一 阅读全文
posted @ 2018-11-24 19:28 CrossPython 阅读(1385) 评论(1) 推荐(1) 编辑
摘要: http://python.jobbole.com/87310/ 阅读全文
posted @ 2018-11-24 18:34 CrossPython 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 对jetbrains公司出品的IDE均有效,以rubymine为例: 打开C:\Program Files\JetBrains\RubyMine 6.3.3\bin,打开 rubymine.exe.vmoptions 文件,修改-Xmx512m 为 -Xmx1024m,其它IDE雷同,此法在linu 阅读全文
posted @ 2018-11-23 19:16 CrossPython 阅读(554) 评论(0) 推荐(0) 编辑
摘要: 干掉 \Lib\fcntl.py 阅读全文
posted @ 2018-11-23 10:28 CrossPython 阅读(1044) 评论(0) 推荐(0) 编辑
摘要: https://docs.djangoproject.com/en/2.1/ref/contrib/sitemaps/ very good 阅读全文
posted @ 2018-11-18 19:13 CrossPython 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 记下来,省得每次google过滤器,变量的显示形式的改变一、形式:小写{{ name | lower }} 二、串联:先转义文本到HTML,再转换每行到 <p> 标签{{ my_text|escape|linebreaks }} 三、过滤器的参数显示前30个字{{ bio | truncatewor 阅读全文
posted @ 2018-11-11 19:44 CrossPython 阅读(1570) 评论(0) 推荐(0) 编辑
摘要: 当时想做一个多条件查询,但是对于要查询的信息,是分布在不同的表里,这就涉及到了多表查询问题。 DjangoBook里提到了一些查询的方式,但是不够全面,就去百度搜了下。 当去网上百度搜多表查询,或多条件查询时,都能搜到,但是相对较综合点的信息,还是比较少。但是为了实现功能, 也思考了不少。下面贴上一 阅读全文
posted @ 2018-11-08 21:46 CrossPython 阅读(1412) 评论(0) 推荐(0) 编辑
摘要: null 不设置时默认设置为False。设置为True时,数据库表字段中将存入NULL的记录。 null和blank组合使用,null=True,blank=True,表示该字段可以为空 blank 默认设置为False。设置为True时,表字段许可无任何输入。设置为False 时,表字段为必须输入 阅读全文
posted @ 2018-11-08 21:05 CrossPython 阅读(3040) 评论(0) 推荐(0) 编辑
摘要: yum install nodejs 阅读全文
posted @ 2018-11-04 21:47 CrossPython 阅读(415) 评论(0) 推荐(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 阅读(193) 评论(0) 推荐(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 阅读(409) 评论(0) 推荐(0) 编辑
摘要: https://blog.csdn.net/pipisorry/article/details/47905781 阅读全文
posted @ 2018-11-02 12:39 CrossPython 阅读(377) 评论(0) 推荐(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 阅读(617) 评论(0) 推荐(0) 编辑
摘要: result = session.execute('insert into ***') session.commit() last_insert_id = result.lastrowid 注意:如果存在多个用户操作数据库,应保持每个用户或者每个请求线程拥有各自隔离的session https:// 阅读全文
posted @ 2018-10-31 23:14 CrossPython 阅读(2644) 评论(0) 推荐(0) 编辑
摘要: models execute via view: 阅读全文
posted @ 2018-10-31 22:52 CrossPython 阅读(1179) 评论(0) 推荐(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 阅读(5868) 评论(0) 推荐(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 阅读(484) 评论(0) 推荐(0) 编辑
摘要: https://blog.csdn.net/yingshukun/article/details/53470424 https://my.oschina.net/auo/blog/222202 阅读全文
posted @ 2018-10-31 09:26 CrossPython 阅读(354) 评论(0) 推荐(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 阅读(317) 评论(0) 推荐(0) 编辑
摘要: https://blog.csdn.net/yingshukun/article/details/53470424 Google翻译实现 阅读全文
posted @ 2018-10-31 08:37 CrossPython 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 前言:最近在公司做爬虫相关的工作,做过数据抓取的都知道,写程序抓取数据的过程并不像平常我们用浏览器打开网页那么简单!大多数的网站为了自己站点的性能和数据安全都设置了各种反爬策略。最常见的就是添加验证码,需要用户登陆,单个IP有次数和频率限制等等!所以广大的爬虫工程师在抓取数据之前都要先调研一下这个网 阅读全文
posted @ 2018-10-30 20:45 CrossPython 阅读(6464) 评论(0) 推荐(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 阅读(233) 评论(0) 推荐(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 阅读(200) 评论(0) 推荐(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 阅读(242) 评论(0) 推荐(0) 编辑
摘要: 前言在爬取某些网页时,登陆界面时经常遇到的一个坎,而现在大多数的网站在登陆时都会要求用户填写验证码。当然,我们可以设计一套机器学习的算法去破解验证码,然而,验证码的形式多种多样,稍微变一下(有些甚至是手机短信验证),整套算法可能就完全无效了,所以去强行破解验证码是一个吃力不讨好的活。本文会以知乎网站 阅读全文
posted @ 2018-10-28 19:24 CrossPython 阅读(772) 评论(0) 推荐(0) 编辑
摘要: 利用django开发web应用, 我们经常需要进行URL重定向,有时候还需要给URL传递额外的参数。比如用户添加文章完成后需要转到文章列表或某篇文章详情。因此熟练掌握HttpResponseDirect, redirect和reverse这三种方法对于Django Web开发是至关重要。今天小编我就 阅读全文
posted @ 2018-10-28 13:38 CrossPython 阅读(2008) 评论(0) 推荐(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 阅读(2456) 评论(0) 推荐(0) 编辑
摘要: 先 django 定好sql框架 再 sqlalchemy 根据框架写。。。 阅读全文
posted @ 2018-10-28 12:46 CrossPython 阅读(130) 评论(0) 推荐(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 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 装饰器模板: 装饰器应用: 阅读全文
posted @ 2018-10-28 09:45 CrossPython 阅读(894) 评论(0) 推荐(0) 编辑
摘要: 装饰器作用 decorator是当今最流行的设计模式之一,很多使用它的人并不知道它是一种设计模式。这种模式有什么特别之处? 有兴趣可以看看Python Wiki上例子,使用它可以很方便地修改对象行为,通过使用类似例中的接口将修改动作封装在装饰对象中。 decorator 可以动态地修改函数、方法或类 阅读全文
posted @ 2018-10-27 21:11 CrossPython 阅读(722) 评论(0) 推荐(0) 编辑
摘要: template 阅读全文
posted @ 2018-10-27 12:35 CrossPython 阅读(971) 评论(0) 推荐(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 阅读(182) 评论(0) 推荐(0) 编辑
摘要: scrapy中有个自带的pipeline工具,ImagesPipeline,可以专门用来储存图片到本地。 但默认储存地址无法配置,所以我们需要写一个自己的pipeline用于储存图片。 先分析一下我们的需求: 1.修改图片路径,路径根据采集到的item中的数据变化; 2.将数据库中保存图片的url更 阅读全文
posted @ 2018-10-26 21:36 CrossPython 阅读(1259) 评论(0) 推荐(0) 编辑
摘要: https://www.jianshu.com/p/d1bb28cbb6a8 scrapy中负责下载文件的是class MyFilesPipeline(FilesPipeline)类 其中负责下载文件的方法是 我们可以很清楚地看到 因为是下载的是文件,所以默认的response参数是为None的,因 阅读全文
posted @ 2018-10-26 21:25 CrossPython 阅读(1894) 评论(0) 推荐(0) 编辑
摘要: hashlib.sha1(to_bytes(url)).hexdigest() hashlib.sha1(to_bytes(url)).hexdigest() MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 阅读全文
posted @ 2018-10-26 19:55 CrossPython 阅读(171) 评论(0) 推荐(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 阅读(271) 评论(0) 推荐(0) 编辑
摘要: 需求分析需求:爬取斗鱼主播图片,并下载到本地 思路: 使用Fiddler抓包工具,抓取斗鱼手机APP中的接口使用Scrapy框架的ImagesPipeline实现图片下载ImagesPipeline实现图片下载的使用方法: 在items中的XxxItem中定义 image_urls 和 images 阅读全文
posted @ 2018-10-26 15:16 CrossPython 阅读(1086) 评论(0) 推荐(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 阅读(165) 评论(0) 推荐(0) 编辑