摘要: yum install nodejs 阅读全文
posted @ 2018-11-04 21:47 CrossPython 阅读(423) 评论(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 阅读(202) 评论(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 阅读(418) 评论(0) 推荐(0)
摘要: https://blog.csdn.net/pipisorry/article/details/47905781 阅读全文
posted @ 2018-11-02 12:39 CrossPython 阅读(383) 评论(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 阅读(630) 评论(0) 推荐(0)
摘要: result = session.execute('insert into ***') session.commit() last_insert_id = result.lastrowid 注意:如果存在多个用户操作数据库,应保持每个用户或者每个请求线程拥有各自隔离的session https:// 阅读全文
posted @ 2018-10-31 23:14 CrossPython 阅读(2687) 评论(0) 推荐(0)
摘要: models execute via view: 阅读全文
posted @ 2018-10-31 22:52 CrossPython 阅读(1196) 评论(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 阅读(5972) 评论(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 阅读(494) 评论(0) 推荐(0)
摘要: https://blog.csdn.net/yingshukun/article/details/53470424 https://my.oschina.net/auo/blog/222202 阅读全文
posted @ 2018-10-31 09:26 CrossPython 阅读(370) 评论(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 阅读(329) 评论(0) 推荐(0)
摘要: https://blog.csdn.net/yingshukun/article/details/53470424 Google翻译实现 阅读全文
posted @ 2018-10-31 08:37 CrossPython 阅读(255) 评论(0) 推荐(0)
摘要: 前言:最近在公司做爬虫相关的工作,做过数据抓取的都知道,写程序抓取数据的过程并不像平常我们用浏览器打开网页那么简单!大多数的网站为了自己站点的性能和数据安全都设置了各种反爬策略。最常见的就是添加验证码,需要用户登陆,单个IP有次数和频率限制等等!所以广大的爬虫工程师在抓取数据之前都要先调研一下这个网 阅读全文
posted @ 2018-10-30 20:45 CrossPython 阅读(6512) 评论(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 阅读(244) 评论(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 阅读(205) 评论(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 阅读(249) 评论(0) 推荐(0)
摘要: 前言在爬取某些网页时,登陆界面时经常遇到的一个坎,而现在大多数的网站在登陆时都会要求用户填写验证码。当然,我们可以设计一套机器学习的算法去破解验证码,然而,验证码的形式多种多样,稍微变一下(有些甚至是手机短信验证),整套算法可能就完全无效了,所以去强行破解验证码是一个吃力不讨好的活。本文会以知乎网站 阅读全文
posted @ 2018-10-28 19:24 CrossPython 阅读(820) 评论(0) 推荐(0)
摘要: 利用django开发web应用, 我们经常需要进行URL重定向,有时候还需要给URL传递额外的参数。比如用户添加文章完成后需要转到文章列表或某篇文章详情。因此熟练掌握HttpResponseDirect, redirect和reverse这三种方法对于Django Web开发是至关重要。今天小编我就 阅读全文
posted @ 2018-10-28 13:38 CrossPython 阅读(2138) 评论(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 阅读(2465) 评论(0) 推荐(0)
摘要: 先 django 定好sql框架 再 sqlalchemy 根据框架写。。。 阅读全文
posted @ 2018-10-28 12:46 CrossPython 阅读(144) 评论(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 阅读(144) 评论(0) 推荐(0)
摘要: 装饰器模板: 装饰器应用: 阅读全文
posted @ 2018-10-28 09:45 CrossPython 阅读(902) 评论(0) 推荐(0)
摘要: 装饰器作用 decorator是当今最流行的设计模式之一,很多使用它的人并不知道它是一种设计模式。这种模式有什么特别之处? 有兴趣可以看看Python Wiki上例子,使用它可以很方便地修改对象行为,通过使用类似例中的接口将修改动作封装在装饰对象中。 decorator 可以动态地修改函数、方法或类 阅读全文
posted @ 2018-10-27 21:11 CrossPython 阅读(758) 评论(0) 推荐(0)
摘要: template 阅读全文
posted @ 2018-10-27 12:35 CrossPython 阅读(978) 评论(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 阅读(190) 评论(0) 推荐(0)
摘要: scrapy中有个自带的pipeline工具,ImagesPipeline,可以专门用来储存图片到本地。 但默认储存地址无法配置,所以我们需要写一个自己的pipeline用于储存图片。 先分析一下我们的需求: 1.修改图片路径,路径根据采集到的item中的数据变化; 2.将数据库中保存图片的url更 阅读全文
posted @ 2018-10-26 21:36 CrossPython 阅读(1311) 评论(0) 推荐(0)
摘要: https://www.jianshu.com/p/d1bb28cbb6a8 scrapy中负责下载文件的是class MyFilesPipeline(FilesPipeline)类 其中负责下载文件的方法是 我们可以很清楚地看到 因为是下载的是文件,所以默认的response参数是为None的,因 阅读全文
posted @ 2018-10-26 21:25 CrossPython 阅读(1954) 评论(0) 推荐(0)
摘要: hashlib.sha1(to_bytes(url)).hexdigest() hashlib.sha1(to_bytes(url)).hexdigest() MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 阅读全文
posted @ 2018-10-26 19:55 CrossPython 阅读(178) 评论(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 阅读(277) 评论(0) 推荐(0)
摘要: 需求分析需求:爬取斗鱼主播图片,并下载到本地 思路: 使用Fiddler抓包工具,抓取斗鱼手机APP中的接口使用Scrapy框架的ImagesPipeline实现图片下载ImagesPipeline实现图片下载的使用方法: 在items中的XxxItem中定义 image_urls 和 images 阅读全文
posted @ 2018-10-26 15:16 CrossPython 阅读(1104) 评论(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 阅读(171) 评论(0) 推荐(0)
摘要: Scrapy生成的调试信息非常有用,但是通常太啰嗦,你可以在Scrapy项目中的setting.py中设置日志显示等级: LOG_LEVEL = 'ERROR' 日志级别 Scrapy日志有五种等级,按照范围递增顺序排列如下:(注意《Python网络数据采集》书中这里有错) CRITICAL - 严 阅读全文
posted @ 2018-10-25 21:34 CrossPython 阅读(3167) 评论(0) 推荐(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 阅读(758) 评论(0) 推荐(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 阅读(246) 评论(0) 推荐(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 阅读(1305) 评论(0) 推荐(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 阅读(371) 评论(0) 推荐(0)
摘要: https://blog.csdn.net/xxm524/article/details/48369623 阅读全文
posted @ 2018-10-25 08:49 CrossPython 阅读(794) 评论(0) 推荐(0)
摘要: //*[@id=”post_content”]/p[1] 意思是:在根节点下面的有一个id为post_content的标签里面的第一个p标签(p[1]) 如果你需要提取的是这个标签的文本你需要在后面加点东西变成下面这样: //*[@id=”post_content”]/p[1]/text() 后面加 阅读全文
posted @ 2018-10-24 21:53 CrossPython 阅读(198) 评论(0) 推荐(0)
摘要: ModelForm表单 save()方法 每一个ModelForm都有一个save()方法,这个方法可以更具绑定的form表单创建并且保存一个数据库对象,ModelForm的子类可以接受一个model的子类作为instance的参数,如果存在那么save()方法会更新这个实例,否则会创建一个新的实例 阅读全文
posted @ 2018-10-24 15:55 CrossPython 阅读(433) 评论(0) 推荐(0)
摘要: start items.py spider.py pipelines.py 通过 item__class__ 是什么类来决定如何处理数据 当然 ItemClass() 类里可以加 def __str__(self): return 'ItemClass" 更直观. 阅读全文
posted @ 2018-10-24 08:43 CrossPython 阅读(235) 评论(0) 推荐(0)