分类 其它 下的文章

在home目录中创建一个 .vimrc文件

vim ~/.vimrc

文件基本配置

" 设置当文件被改动时自动载入
set autoread
" quickfix模式
autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr>
"代码补全 
set completeopt=preview,menu 
"允许插件  
filetype plugin on
"共享剪贴板  
set clipboard=unnamed 
"从不备份  
set nobackup
"make 运行
:set makeprg=g++\ -Wall\ \ %
"自动保存
set autowrite
set ruler                   " 打开状态栏标尺
set cursorline              " 突出显示当前行
set magic                   " 设置魔术
set guioptions-=T           " 隐藏工具栏
set guioptions-=m           " 隐藏菜单栏
"set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\
" 设置在状态行显示的信息
set foldcolumn=0
set foldmethod=indent 
set foldlevel=3 
set foldenable              " 开始折叠
" 不要使用vi的键盘模式,而是vim自己的
set nocompatible
" 语法高亮
set syntax=on
" 去掉输入错误的提示声音
set noeb
" 在处理未保存或只读文件的时候,弹出确认
set confirm
" 自动缩进
set autoindent
set cindent
" Tab键的宽度
set tabstop=4
" 统一缩进为4
set softtabstop=4
set shiftwidth=4
" 不要用空格代替制表符
set noexpandtab
" 在行和段开始处使用制表符
set smarttab
" 显示行号
set number
" 历史记录数
set history=1000
"禁止生成临时文件
set nobackup
set noswapfile
"搜索忽略大小写
set ignorecase
"搜索逐字符高亮
set hlsearch
set incsearch
"行内替换
set gdefault
"编码设置
set enc=utf-8
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
"语言设置
set langmenu=zh_CN.UTF-8
set helplang=cn
" 我的状态行显示的内容(包括文件类型和解码)
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%]
" 总是显示状态行
set laststatus=2
" 命令行(在状态行下)的高度,默认为1,这里是2
set cmdheight=2
" 侦测文件类型
filetype on
" 载入文件类型插件
filetype plugin on
" 为特定文件类型载入相关缩进文件
filetype indent on
" 保存全局变量
set viminfo+=!
" 带有如下符号的单词不要被换行分割
set iskeyword+=_,$,@,%,#,-
" 字符间插入的像素行数目
set linespace=0
" 增强模式中的命令行自动完成操作
set wildmenu
" 使回格键(backspace)正常处理indent, eol, start等
set backspace=2
" 允许backspace和光标键跨越行边界
set whichwrap+=<,>,h,l
" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)
set mouse=a
set selection=exclusive
set selectmode=mouse,key
" 通过使用: commands命令,告诉我们文件的哪一行被改变过
set report=0
" 在被分割的窗口间显示空白,便于阅读
set fillchars=vert:\ ,stl:\ ,stlnc:\
" 高亮显示匹配的括号
set showmatch
" 匹配括号高亮的时间(单位是十分之一秒)
set matchtime=1
" 光标移动到buffer的顶部和底部时保持3行距离
set scrolloff=3
" 为C程序提供自动缩进
set smartindent
" 高亮显示普通txt文件(需要txt.vim脚本)
 au BufRead,BufNewFile *  setfiletype txt
"自动补全
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
":inoremap { {<CR>}<ESC>O
":inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i
function! ClosePair(char)
	if getline('.')[col('.') - 1] == a:char
		return "\<Right>"
	else
		return a:char
	endif
endfunction
filetype plugin indent on 
"打开文件类型检测, 加了这句才可以用智能补全
set completeopt=longest,menu

创建普通用户

# 创建用户,并指定用户目录,加入用户组sudo useradd username -d /home/username -m
#设置密码
sudo passwd username

#给用户增加sudo权限
sudo chmod u+w /etc/sudoers
#编辑权限文件
sudo vi /etc/sudoers
#在 root ALL=(ALL:ALL) ALL 添加一行
	username ALL=(ALL:ALL) ALL

#恢复文件权限
sudo chmod u-w /etc/sudoers

解决远程用户登录问题

sudo vi /etc/passwd

在追后一行追加 :/bin/bash

username:x:1001:1001::/home/biyunsheng:/bin/bash

·1、更改host文件 文件地址: C:\Windows\System32\Drivers\etc

​ 如果不能直接修改,可拷贝到桌面修改后再复制回去

2、在host文件追加

#github
192.30.253.112 github.com 

151.101.113.194 github.global.ssl.fastly.net

​ ip 地址通过以下两个网站可查

http://github.com.ipaddress.com/

http://github.global.ssl.fastly.net.ipaddress.com/

3、打开cmd执行dns刷新命令

ipconfig /flushdns

selenium接管方式

1、指定启动参数打开浏览器

# 指定chrome 远程调试接口与用户目录chrome.exe --remote-debugging-port=9222 --user-data-dir="C:\selenum\AutomationProfile"

2selenium接管

self.options = webdriver.ChromeOptions()
self.options.add_experimental_option("debuggerAddress", "127.0.1:9222")
self.chromeDriver = webdriver.Chrome(driverPath, options=self.options)

chrome远程调试原理分析(CDP协议)

参考链接

https://chromedevtools.github.io/devtools-protocol/

https://chromedevtools.github.io/devtools-protocol/

https://ceshiren.com/t/topic/3567

https://www.daimajiaoliu.com/daima/4eee866b8900402

协议

webdriver协议

使用 DevTools 作为协议客户端

开发者工具前端可以附加到远程运行的 Chrome 实例进行调试。要使此方案正常运行,您应该使用 remote-debugging-port 命令行开关启动您的主机Chrome 实例

chrome.exe --remote-debugging-port=9222

然后,您可以使用不同的用户配置文件启动一个单独的客户端Chrome 实例:

chrome.exe --user-data-dir=<某个目录>

现在,您可以从客户端导航到给定端口并附加到任何发现的选项卡以进行调试:http://localhost:9222

监听协议

这对于理解 DevTools 前端如何使用协议特别方便。您可以在发生时查看所有请求/响应和方法。

协议监视器的屏幕截图

单击 DevTools 右上角的齿轮图标以打开设置面板。选择设置左侧的实验。打开“Protocol Monitor”,然后关闭并重新打开 DevTools。现在单击 ⋮ 菜单图标,选择更多工具,然后选择协议监视器

您还可以使用协议监视器(版本 92.0.4497.0+)发出您自己的命令。如果该命令不需要任何参数,请在“协议监视器”面板底部的提示中键入该命令,然后按 Enter,例如, Page.captureScreenshot。如果命令需要参数,请将它们作为 JSON 提供,例如 {"command":"Page.captureScreenshot","parameters":{"format": "jpeg"}}.

http获取启动信息

GET /json/version

Browser version metadata

{    "Browser": "Chrome/72.0.3601.0",    "Protocol-Version": "1.3",    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3601.0 Safari/537.36",    "V8-Version": "7.2.233",    "WebKit-Version": "537.36 (@cfede9db1d154de0468cb0538479f34c0755a0f4)",    "webSocketDebuggerUrl": "ws://localhost:9222/devtools/browser/b0b8a4fb-bb17-4359-9533-a8d9f3908bd8"}

GET /json or /json/list

A list of all available websocket targets.

[ {
  "description": "",
  "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/DAB7FB6187B554E10B0BD18821265734",
  "id": "DAB7FB6187B554E10B0BD18821265734",
  "title": "Yahoo",
  "type": "page",
  "url": "https://www.yahoo.com/",
  "webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/DAB7FB6187B554E10B0BD18821265734"} ]

GET /json/protocol/

The current devtools protocol, as JSON:

{
  "domains": [
      {
          "domain": "Accessibility",
          "experimental": true,
          "dependencies": [
              "DOM"
          ],
          "types": [
              {
                  "id": "AXValueType",
                  "description": "Enum of possible property types.",
                  "type": "string",
                  "enum": [
                      "boolean",
                      "tristate",// ...

GET /json/new?{url}

Opens a new tab. Responds with the websocket target data for the new tab.

GET /json/activate/{targetId}

Brings a page into the foreground (activate a tab).

For valid targets, the response is 200: "Target activated". If the target is invalid, the response is 404: "No such target id: {targetId}"

GET /json/close/{targetId}

Closes the target page identified by targetId.

For valid targets, the response is 200: "Target is closing". If the target is invalid, the response is 404: "No such target id: {targetId}"

WebSocket /devtools/page/{targetId}

The WebSocket endpoint for the protocol.

GET /devtools/inspector.html

A copy of the DevTools frontend that ship with Chrome.

远程调试步骤

1、设置远程调试端口

chrome.exe --remote-debugging-port=9222

2、http获取浏览信息

postman    http://localhost:9222/json/version
{    "Browser": "Chrome/91.0.4472.124",    "Protocol-Version": "1.3",    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",    "V8-Version": "9.1.269.36",    "WebKit-Version": "537.36 (@7345a6d1bfcaff81162a957e9b7d52649fe2ac38)",    "webSocketDebuggerUrl": "ws://localhost:9222/devtools/browser/325848c7-f588-4b2a-8d53-871d0c407498"}

3、ws执行后续命令示例

# 获取sessionidimport websocketimport jsonws = websocket.create_connection("ws://localhost:9222/devtools/browser/325848c7-f588-4b2a-8d53-871d0c407498")cmd = {"id": 100, "method": "Target.attachToTarget", "params": {"targetId":"C6D11457622705623B8F5381612D197D", "flatten":True}}data = json.dumps(cmd, ensure_ascii=False)ws.send(data)while 1:
    result = ws.recv()
    print(result)

4、event示例

import websocketimport jsonws = websocket.create_connection("ws://localhost:9222/devtools/page/7064B86A54979CA238AABB1784858038")cmd = {"id": 1, "method": "Page.enable", "params": {"windowId": 1, "bounds":{

}}}data = json.dumps(cmd, ensure_ascii=False)ws.send(data)while 1:
    result = ws.recv()
    print(result)
E:\Desktop\RPAWork\CBSEditor\branches\develop_v3.0\RpaStudioPublish\public\python\python.exe E:/Desktop/RPAWork/CSEditorPython/trunk/compentsAdministration/2.py
{"id":1,"result":{}}
{"method":"Page.frameStartedLoading","params":{"frameId":"7064B86A54979CA238AABB1784858038"}}
{"method":"Page.frameDetached","params":{"frameId":"A099BBAD2608A370D9C76CA5479B5621","reason":"remove"}}
{"method":"Page.frameNavigated","params":{"frame":{"id":"7064B86A54979CA238AABB1784858038","loaderId":"95332EA5BBB3B9346ED939DB007F59D0","url":"https://fanyi.baidu.com/","urlFragment":"#en/zh/Types","domainAndRegistry":"baidu.com","securityOrigin":"https://fanyi.baidu.com","mimeType":"text/html","adFrameType":"none","secureContextType":"Secure","crossOriginIsolatedContextType":"NotIsolated","gatedAPIFeatures":["SharedArrayBuffersTransferAllowed"]}}}
{"method":"Page.frameAttached","params":{"frameId":"CAC1E51A034347E0CD90FAC57B040682","parentFrameId":"7064B86A54979CA238AABB1784858038"}}
{"method":"Page.frameStartedLoading","params":{"frameId":"CAC1E51A034347E0CD90FAC57B040682"}}
{"method":"Page.frameNavigated","params":{"frame":{"id":"CAC1E51A034347E0CD90FAC57B040682","parentId":"7064B86A54979CA238AABB1784858038","loaderId":"62CC3D0059086BA4A88DB784C824BFD6","name":"doc-view-iframe","url":"about:blank","domainAndRegistry":"","securityOrigin":"://","mimeType":"text/html","adFrameType":"none","secureContextType":"Secure","crossOriginIsolatedContextType":"NotIsolated","gatedAPIFeatures":["SharedArrayBuffersTransferAllowed"]}}}
{"method":"Page.frameStoppedLoading","params":{"frameId":"CAC1E51A034347E0CD90FAC57B040682"}}
{"method":"Page.domContentEventFired","params":{"timestamp":873617.921655}}
{"method":"Page.frameAttached","params":{"frameId":"E4F8EB74C7D088A7D98D9F2B6C02F25C","parentFrameId":"7064B86A54979CA238AABB1784858038","stack":{"callFrames":[{"functionName":"qL","scriptId":"280","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2008-s.js","lineNumber":0,"columnNumber":89227},{"functionName":"cf","scriptId":"280","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2008-s.js","lineNumber":0,"columnNumber":108246},{"functionName":"yk","scriptId":"280","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2008-s.js","lineNumber":0,"columnNumber":108414},{"functionName":"ck","scriptId":"280","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2008-s.js","lineNumber":0,"columnNumber":128015},{"functionName":"GZ.<computed>.<computed>","scriptId":"280","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2008-s.js","lineNumber":0,"columnNumber":128242},{"functionName":"N5","scriptId":"280","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2008-s.js","lineNumber":0,"columnNumber":138720},{"functionName":"y","scriptId":"280","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2008-s.js","lineNumber":0,"columnNumber":39001},{"functionName":"","scriptId":"280","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2008-s.js","lineNumber":0,"columnNumber":138980},{"functionName":"_iwWM","scriptId":"280","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2008-s.js","lineNumber":0,"columnNumber":138987},{"functionName":"","scriptId":"280","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2008-s.js","lineNumber":0,"columnNumber":138992}]}}}
{"method":"Page.frameStartedLoading","params":{"frameId":"E4F8EB74C7D088A7D98D9F2B6C02F25C"}}
{"method":"Page.frameStoppedLoading","params":{"frameId":"E4F8EB74C7D088A7D98D9F2B6C02F25C"}}
{"method":"Page.frameDetached","params":{"frameId":"E4F8EB74C7D088A7D98D9F2B6C02F25C","reason":"remove"}}
{"method":"Page.frameAttached","params":{"frameId":"A85725E42A62F74C9D8873D8F81AD2BA","parentFrameId":"7064B86A54979CA238AABB1784858038","stack":{"callFrames":[{"functionName":"ix","scriptId":"318","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2060-s.js?v=0.14359652757150543","lineNumber":1,"columnNumber":62835},{"functionName":"aY","scriptId":"318","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2060-s.js?v=0.14359652757150543","lineNumber":1,"columnNumber":100587},{"functionName":"","scriptId":"318","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2060-s.js?v=0.14359652757150543","lineNumber":1,"columnNumber":101855},{"functionName":"xx.<computed>","scriptId":"318","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2060-s.js?v=0.14359652757150543","lineNumber":1,"columnNumber":109310},{"functionName":"v1","scriptId":"318","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2060-s.js?v=0.14359652757150543","lineNumber":1,"columnNumber":101811},{"functionName":"vW","scriptId":"318","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2060-s.js?v=0.14359652757150543","lineNumber":1,"columnNumber":102541},{"functionName":"p","scriptId":"318","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2060-s.js?v=0.14359652757150543","lineNumber":1,"columnNumber":144953},{"functionName":"Me.<computed>.<computed>","scriptId":"318","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2060-s.js?v=0.14359652757150543","lineNumber":1,"columnNumber":145288},{"functionName":"PN","scriptId":"318","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2060-s.js?v=0.14359652757150543","lineNumber":1,"columnNumber":147945},{"functionName":"D","scriptId":"318","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2060-s.js?v=0.14359652757150543","lineNumber":1,"columnNumber":41294},{"functionName":"","scriptId":"318","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2060-s.js?v=0.14359652757150543","lineNumber":1,"columnNumber":148232},{"functionName":"_3Ku4","scriptId":"318","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2060-s.js?v=0.14359652757150543","lineNumber":1,"columnNumber":148242},{"functionName":"","scriptId":"318","url":"https://dlswbr.baidu.com/heicha/mw/abclite-2060-s.js?v=0.14359652757150543","lineNumber":1,"columnNumber":148247}]}}}
{"method":"Page.frameStartedLoading","params":{"frameId":"A85725E42A62F74C9D8873D8F81AD2BA"}}
{"method":"Page.frameStoppedLoading","params":{"frameId":"A85725E42A62F74C9D8873D8F81AD2BA"}}
{"method":"Page.frameDetached","params":{"frameId":"A85725E42A62F74C9D8873D8F81AD2BA","reason":"remove"}}
{"method":"Page.loadEventFired","params":{"timestamp":873623.526458}}
{"method":"Page.frameStoppedLoading","params":{"frameId":"7064B86A54979CA238AABB1784858038"}}

工欲善其事,必先利其器!