远程连接服务器的一些配置:学习笔记与要点整理
ssh免密连接服务器:生成秘钥: 执行下面命令,默认生成位置是~/.ssh 12ssh-keygenssh-keygen -t rsa -C "youremail@example.com" 系统会询问你文件名和秘钥密码,可以一路回车过去,会生成两个文件: id_rsa 私钥 id_rsa.pub 公钥 连接的客户端:修改 vim ~/.ssh/config,添加如下的信息: 1234567891011121314Host nbUser xxxPort 22HostName xxxxxIdentityFile ~/.ssh/id_rsaIdentitiesOnly yes注释:Host 别名HostName 指定登录的主机名或IP地址Port 指定登录的端口号User 登录用户名IdentityFile 登录的公钥文件IdentitiesOnly 只接受SSH key 登录 把本地的公钥传送到服务器: 1ssh-copy-id -i ~/.ssh/id_rsa.pub xxx@<ip> 个人用户环境配置修改rm...
macOS 安装pyenv遇到的问题
加速pyenv下载将源码下好放在~/.pyenv/cache目录, pyenv检查有源码就会直接使用cache目录里的源码进行安装. 123$ mkdir -pv ~/.pyenv/cache$ wget https://www.python.org/ftp/python/<version>/Python-<version>.tar.xz$ pyenv install <version> 1wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tar.xz pycahrm无法判断pyenv多个python版本https://github.com/concordusapps/pyenv-implict mac无法安装python3解决方案1CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/incl...
Twisted之@inlineCallbacks
inlineCallbacks文档:https://twistedmatrix.com/documents/current/api/twisted.internet.defer.inlineCallbacks.html 1.inlineCallbacks 是一个decorator,它可以把一个generator函数(使用了yield语句的函数)变成是一系列的异步callbacks的调用。2.调用decoratored by inlineCallbacks 的函数的时候,我们不需要调用send、next等函数把yield的结果发送给generator,inlineCallbacks负责这一切,保证generator可以顺利跑完(前提是generator本身不抛异常)3.如果yield的是defer,那么generator会暂停,直到返回的defer被fired。如果defer是success的,则返回defer的结果,否则,就抛异常(普通的Exception,而不是Failue)12345678910111213from twisted.internet import reacto...
Twisted之Thread:callFromThread和callInThr…
callFromThread和callInThread区别1234567891011121314151617181920212223242526272829303132333435363738import timefrom twisted.internet import reactorfrom twisted.internet import deferfrom twisted.internet.interfaces import IReactorThreadsimport loggingfrom twisted.python.threadpool import ThreadPoollogging.basicConfig( level=logging.DEBUG, # 定义输出到文件的log级别, format='%(asctime)s : %(levelname)s "%(threadName)s %(thread)d %(message)s" %(message)s', # 定义输出log的格式 datefmt=...
Twisted之各种callback
callLater(延迟执行,多少秒后执行某任务)12345678910111213from twisted.internet import reactordef f(s): print('this will run 3.5 seconds after it was scheduled: %s' % s) reactor.stop()reactor.callLater(3.5, f, 'hello, world')# f() will only be called if the event loop is started.reactor.run() LoopingCall间隔时间执行某任务12345678910from twisted.internet import reactor, taskdef f(s): print(s)loop = task.LoopingCall(f, 'hello, world')# Start looping every 1 second.loop.start(1)re...
Twisted之twisted.Web.client.Agent
文档https://twistedmatrix.com/documents/current/api/twisted.web.client.html Agent的用法Agent is a very basic HTTP client. It supports HTTP and HTTPS scheme URIs. demo0112345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061from scrapy.core.downloader.contextfactory import ScrapyClientContextFactoryfrom twisted.internet import reactorfrom twisted.web.client import Agentfrom twisted.web.http_headers import Headersfrom twisted.internet.ssl imp...
Twisted简介:学习笔记与要点整理
1.介绍 熟悉scrpay爬虫框架的人,对Twisted应该不太陌生,scrapy底层请求就是基于Twisted框架实现的。 官方定义: Twisted is an event-based framework for internet applications, supporting Python 2.7 and Python 3.5+. It includes modules for many different purposes, including the following: twisted.web: HTTP clients and servers, HTML templating, and a WSGI server twisted.conch: SSHv2 and Telnet clients and servers and terminal emulators twisted.words: Clients and servers for IRC, XMPP, and other IM protocols twisted.mail: IMAPv4, POP3...
Android刷机教程:权限
刷机相关的词汇解释权限 第三方软件权限(低) 比如,每次app启动都会向用户请求读取信息,当然流氓软件你不同意,APP直接不让你启动 用户权限(中) 基本的增删改查,安装app,卸载app,设置登陆密码,搜索浏览本地文件等 Root权限(超级用户,最高) 至高无上的权限 分区 Boot分区 启动和引导文件 Kernel(内核) Ramdisk(虚拟内存) System分区 系统分区 操作系统和预装的软件 Data分区 用户数据,包括应用,音视频,图片,文档,系统设置等 Cache 缓存 Recovery 恢复和更新其他分区的内容 Android7.0以后分为A,B区(Boot,System)A区:日常使用的分区B区:备用分区 …后续还可能会改变 Bootloader锁Bootloader中文名称为“启动加载”。在嵌入式操作系统中,BootLoader是在操作系统内核运行之前运行,它可以初始化硬件设备、建立内存空间映射图,从而将系统的软硬件环境带到一个合适状态,以便为最终调用操作系统内核准备好正确的环境。 Bootloader引导启动时检...
Scrapy基础:[Scrapy](https://doc.scr…
Scrapy新建一个项目的命令:123456789101112131415161718192021scrapy startproject 项目的名称产生如下的目录:tutorial/ scrapy.cfg tutorial/ __init__.py items.py pipelines.py settings.py spiders/ __init__.py ...这些文件分别是:scrapy.cfg: 项目的配置文件tutorial/: 该项目的python模块。之后您将在此加入代码。tutorial/items.py: 项目中的item文件.tutorial/pipelines.py: 项目中的pipelines文件.tutorial/settings.py: 项目的设置文件.tutorial/spiders/: 放置spider代码的目录. 新建一个爬虫项目:123456Available templates: basic crawl ...
Scrapy的运行方式:scrapy不同的运行方式
scrapy不同的运行方式CrawlerProcess1234567custom_settings = {} # 项目的配置文件project_settings = get_project_settings()settings = dict(project_settings.copy())settings.update(custom_settings.get('settings'))process = CrawlerProcess(settings)process.crawl(Example2Spider)process.start() CrawlerRunner12345678910configure_logging()runner = CrawlerRunner()@defer.inlineCallbacksdef crawl(): yield runner.crawl(Example2Spider) # yield runner.crawl() reactor.stop()# 调用crawl()crawl()rea...