摘要: 在项目文件夹中的 __init__.py 中添加如下代码: import pymysql pymysql.install_as_MySQLdb() 修改settings中有数据库的设置 # 'default': { # 'ENGINE': 'django.db.backends.sqlite3', 阅读全文
posted @ 2020-09-08 08:20 spidernyp 阅读(90) 评论(0) 推荐(0) 编辑
摘要: cmd python import re import requests t = requests.get("http://xxx.xxx") t.encoding = 'utf-8' t.text 则正确显示 阅读全文
posted @ 2020-08-06 12:49 spidernyp 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 将spider文件直接拷到服务器上,执行,提示spider not found kwq 回到本地测试,发现只有scrapy genspider kwq sxmu.edu.cn生成文件后,再按原先的爬虫文件格式修改才可以被正常执行 后在服务器上测试,发现确实如此。 本次测试,涉及到pip文件和item 阅读全文
posted @ 2020-08-03 23:04 spidernyp 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 查看linux内核版本 cat /proc/version 查看操作系统 cat /etc/redhat-release 启动 systemctl start firewalld 查看状态 systemctl status firewalld 或者 firewall-cmd --state 停止 s 阅读全文
posted @ 2020-07-23 15:55 spidernyp 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 本地开发一个新闻站的数据分析平台,花三天时间终于成功部署在linux平台上。 几年前,实施过linux的web服务器,对linux的操作只了解一些皮毛,这次部署也是按部就班、战战兢兢,参考了许多网友大牛的技术资料,也踩过了好多坑,现在整理一下。 基础条件:centos7.8 1.系统更新,安装基础环 阅读全文
posted @ 2020-07-21 21:19 spidernyp 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 解决方法: db.collection.find().sort([("name", 1), ("age" , 1)]) 原因:在python中只能使用列表进行排序,不能使用字典 阅读全文
posted @ 2020-05-02 10:58 spidernyp 阅读(1494) 评论(0) 推荐(2) 编辑
摘要: db.getCollection('syxw').find({'click':{$type:2}}).forEach(function(x){x.click=NumberInt(x.click);db.getCollection('syxw').save(x);}) use sxmu 再执行,将sy 阅读全文
posted @ 2020-05-02 10:40 spidernyp 阅读(1230) 评论(0) 推荐(0) 编辑
摘要: 1异常处理 常规办法 try: question = Question.objects.get(pk = question_id) except Question.DoesNotExist: raise Http404("sorry no exist") 新写法 from django.shortc 阅读全文
posted @ 2020-04-22 12:12 spidernyp 阅读(344) 评论(0) 推荐(0) 编辑
摘要: 在sublime中安装less转css插件 1.在sublime.中安装less2css,提示需要安装lessc 2.在node.js中,npm install lessc -g 3.在sublime中提示需clean-css插件 4.在node.js中,安装less-plugin-clean-cs 阅读全文
posted @ 2020-04-13 10:10 spidernyp 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 找到site-packages\matplotlib\mpl-data\matplotlibrc中的 font.serif和font.sans-serif前添加“SimHei” 即可正常显示微软雅黑也可以添加其它字体,这样可以一劳永逸的解决中文显示问题,不用在程序中定义font 阅读全文
posted @ 2020-04-01 23:05 spidernyp 阅读(117) 评论(0) 推荐(0) 编辑