首页
网络资源
技术分享
云资源
分享你我
行动起来,活在当下
累计撰写
112
篇文章
累计创建
13
个标签
累计收到
0
条评论
栏目
首页
网络资源
技术分享
云资源
目 录
CONTENT
以下是
技术分享
相关的文章
C# 使用NAudio实现录音并过滤大部分无用的杂音并使用python 识别录音内容
<h6>NAudio 录音帮类</h6> <pre><code> public interface ISpeechRecorder { void SetFileName(string fileName); void StartRec(); void StopRec(); } public class NAudioRecorder : ISpeechRecorder { #region var /// <summary></summary><!--autointro--></code></pre><!--autointro--><!--101-->
2022-09-27
12
0
0
技术分享
java/C# 调用unipush2.0
<h4 id="h4--uniapp-unipush-"><a name="首先按照uniapp的文档添加 unipush服务" class="reference-link" href="#"></a><span class="header-link octicon octicon-link"></span>首先按照uniapp的文档添加 unipush服务</h4><p><a href="https://uniapp.dcloud.net.cn/unipush-v2.html" title="添加unipush服务文档">添加unipush服务文档</a><br><strong>注意:<br>没有使用 uni-id-pages 时执行云函数只有一个”opendb-tempdata”表并不会像文档所说有三个表</strong><br><img src="https://www.javalc.com/zb_users/upload/2022/08/202208121558522965071.png" alt=""></p> <h4 id="h4--package-json-"><a name="修改 package.json文件" class="reference-link" href="#"></a><span class="header-link octicon octicon-link"></span>修改 package.json文件</h4><pre><code class="language-json">{ "name": "uni-push-api", "dependencies": {}, "version": "1.0.0", "main": "index.js", "extensions": { "uni-cloud-push": {} } } </code></pre> <p><strong>注意此文件内不能出现注释</strong></p> <h4 id="h4--index-js-"><a name="修改同级目录中的 index.js文件" class="reference-link" href="#"></a><span class="header-link octicon octicon-link"></span>修改同级目录中的 index.js文件</h4><p>```json<br>‘use strict’;</p> <p>const uniPush = uniCloud.getPushManager({<br> appId: “<strong>UNI</strong>120F7BB”<br>}) //注意这里需要传入你的应用appId</p> <p>exports.main = async (event, context) =<!--autointro--></p> <!--100-->
2022-08-12
4
0
0
技术分享
xray 前置实现复用443端口
<h2 id="应用情景" tabindex="-1" style="scroll-behavior: smooth; transition: border-color var(--t-color); line-height: 1.25; font-size: 1.65rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--c-border); margin-top: calc(0.5rem - var(--navbar-height)); padding-top: calc(1rem + var(--navbar-height)); margin-bottom: 0px; color: rgb(44, 62, 80); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; white-space: normal; background-color: rgb(255, 255, 255);"><!--autointro--><!--99-->
2022-07-17
10
0
0
技术分享
青龙面板使用selenium
<p><strong><span style="color: #4D4D4D; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif, SimHei, SimSun; background-color: #FFFFFF;"></span></strong></p><!--autointro--><!--98-->
2022-07-16
10
0
0
技术分享
httpcanary(小黄鸟)v3.3.6 平行空间补丁
<p><img src="https://www.javalc.com/zb_users/upload/2022/07/202207131622033592890.jpg" alt="bdf6c6e7df4a3d0a2bc04782cebbda0.jpg"/></p><p><img src="https://www.javalc.com/zb_users/upload/2022/07/202207131622134833483.jpg" alt="cada26ee97ce494ddee1913fb1b604c.jpg"/></p><!--autointro--><!--97-->
2022-07-13
9
0
0
技术分享
af-table-column 插件改版支持 VUE3 TS(el-table 自适应列宽)
<p><br/></p><p>新建组件:AFTableColumn.vue</p><pre class="brush:js;toolbar:false"><template> <!--判断 slots.default可知道是否存在子元素--> <el-table-column v-if="slots.default" v-bind="attrs" :class-name="className" :min-width="minWidth"> <template #default="scope"> <slot v-bind="scope"></slot> </template> </el-table-column> <!--使用 slot 自定义 header--> <el-table-column v-else-if="slots.header" v-bind="attrs" :class-name="className" :min-width="minWidth"> <template #header="scope"> <slot name="header" v-bind="scope"></slot> </template> </el-table-column> <!--默认情况使用原始 el-table-column--> <el-table-column v-else :class-name="className" v-bind="attrs" :min-width="minWidth"> </el-table-column> </template> <script lang="ts"> export default { name: 'af-table-column', // inheritAttrs: false, } </script> <script setup lang="ts" name="af-table-column"> import { getCurrentInstance, ref, reactive, watch, computed, nextTick, useAttrs, useSlots } from 'vue' import $consts from '../../configs/constants'; const { proxy } = getCurrentInstance() as any; const attrs = useAttrs() as any; const slots = useSlots(); let minLength = ref(10); // 初始也不要写成0, 避免未及时设置宽度太丑 let getComputedWidth = ref(10); // 自定义列中获取元素计算的宽度 const values = computed(() => { const data = proxy.$parent.data || [] return data.map((item: any) => item[attrs.prop]) }) // 是否自适应列宽, 默认是 const isFit = computed(() => { return (proxy.$parent.$attrs.autoFit === undefined && attrs.fit === undefined) || (proxy.$parent.$attrs.autoFit === false && attrs.fit !== undefined) }) // 为存在scope的添加className const className = computed(() => { const parentClass = attrs['class-name'] || '' const classPre = attrs.prop || `encode-${transChar(attrs.label)}` // 有的列因为有slotScope而不给prop return classPre ? `${parentClass} ${classPre}-column` : '' }) // 列最小宽度 const minWidth = computed(() => { if (!attrs.label) return undefined; if (!isFit.value) return undefined; const maxOne = Math.max(minLength.value, attrs.label.length * (fontRate.value as any).CHAR_RATE) * fontSize.value + 20; return attrs.width || Math.max(maxOne, getComputedWidth.value) }) // 字体大小 const fontSize = computed(() => attrs.fontSize || $consts.fontSize) // 字体比例 const fontRate = computed(() => { return { ...$consts.fontRate, // 默认值 ...attrs.fontRate || {}, // 父组件属性 } }) watch(values, (val: any) => { return isFit.value !== false && nextTick(() => { // 详情中的列表需要在nextTick才能生效 if (!slots.default) { // 存在自定义节点 minLength.value = getMaxLength(val); return; } setTimeout(() => { // 首次获取不到子节点, setTimeout才行 // 可能存在贴边列, 需要使用包含 fixed 的类名 const bodyWrapper = attrs.fixed ? (document as any).querySelector(`.el-table__fixed${attrs.fixed === 'right' ? `-${attrs.fixed}` : ''}`).querySelector('.el-table__fixed-body-wrapper') : document.querySelector('.el-table__body-wrapper') const nodes = bodyWrapper.querySelectorAll(`.${attrs.prop || `encode-${transChar(attrs.label)}`}-column`) if (nodes.length) { // 有可能会来不及获取nodes, 就切换菜单进入下一页了, 再研究吧 const target = reactive<Array<String>>([]); const getComputedWidths = reactive<Array<number>>([]); Array.from(nodes).map((item: any) => { let text = item.innerText; target.push(text); // 有可能存在自定义列内容超出容器, 取 scrollWidth 才行 getComputedWidths.push(item.querySelector('.cell').scrollWidth); }) getComputedWidth.value = Math.max(...getComputedWidths); minLength.value = getMaxLength(target); } }, 0) }) }) /** * 获取数组中元素按字体比例最长长度 * @param arr */ const getMaxLength = (arr: any) => { return arr.reduce((length: any, item: any) => { if (item) { const str = item.toString() const char = str.match(/[\u2E80-\u9FFF]/g) const charLength = char ? char.length : 0 const num = str.match(/\d|\./g) const numLength = num ? num.length : 0 const otherLength = str.length - charLength - numLength let newLength = charLength * $consts.fontRate.CHAR_RATE + numLength * $consts.fontRate.NUM_RATE + otherLength * $consts.fontRate.OTHER_RATE if (str.includes('\n')) newLength = getMaxLength(str.split('\n')) if (length < newLength) { length = newLength } } return length }, 0) } /** * 转换汉字为class支持的字母 * @param char */ const transChar = (char: any) => { return encodeURIComponent(char).replace(/[^a-zA-z]/g, 'eUC') } </script></pre><!--autointro--><!--96-->
2022-06-15
17
0
0
技术分享
python-eel-vite-vue-ts 构建桌面应用
<p>源码地址:<a href="https://github.com/Child-Cheng/python-eel-vite-vue-ts" _src="https://github.com/Child-Cheng/python-eel-vite-vue-ts">https://github.com/Child-Cheng/python-eel-vite-vue-ts</a></p><p>效果图:</p><p><img src="https://www.javalc.com/zb_users/upload/2022/05/202205241450164557089.png" alt="image.png"/></p><!--autointro--><!--95-->
2022-05-24
8
0
0
技术分享
CefSharp (100.0.23)版本编译添加MP4支持、开启ffmpeg支持
<p>发布x64、x86地址:</p><p>链接:https://pan.baidu.com/s/1NvFvEv5L-4U8Ny2Ri7GmiA?pwd=6666 <br/></p><p>提取码:6666</p><p><br/></p><p>源码地址:</p><p><a href="https://drive.google.com/drive/folders/1TPRRrLRtRS6vNhmIBCfAZRIKwhO-DKnW?usp=sharing" _src="https://drive.google.com/drive/folders/1TPRRrLRtRS6vNhmIBCfAZRIKwhO-DKnW?usp=sharing"></a></p><!--autointro--><!--94-->
2022-04-21
14
0
0
技术分享
python selenium 封装使用(处理反爬)
<pre class="brush:python;toolbar:false"># coding=utf-8 """ 此文件为selenium常用方法二次封装文件 """ from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.action_chains import ActionChains # 处理鼠标事件 from selenium.webdriver.support.select import Select # 用于处理下拉框 from selenium.common.exceptions import * # 用于处理异常 from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait # 用于处理元素等待 from PIL import Image, ImageEnhance import pytesseract, re import time from urllib.parse import urlparse import sys class BrowserHelper(object): """ selenium框架的主要类 """ original_window = None def __init__(self, browser='chrome'): """ 运行初始化方法默认chrome,当然,你也可以传入一个其他浏览器名称, """ if browser == "firefox" or browser == "ff": self.driver = webdriver.Firefox() elif browser == "chrome": options = Options(); options.add_argument("--disable-blink-features=AutomationControlled"); options.add_experimental_option("excludeSwitches", ["enable-automation"]); options.add_experimental_option('useAutomationExtension', False); self.driver = webdriver.Chrome(options=options) elif browser == "internet explorer" or browser == "ie": self.driver = webdriver.Ie() elif browser == "opera": self.driver = webdriver.Opera() elif browser == "chrome_headless": options = Options(); options.add_argument('--headless'); options.add_argument("--disable-blink-features=AutomationControlled"); options.add_experimental_option("excludeSwitches", ["enable-automation"]); options.add_experimental_option('useAutomationExtension', False); self.driver = webdriver.Chrome(options=options) elif browser == 'edge': self.driver = webdriver.Edge() else: raise NameError( "找不到 %s 浏览器,你应该从这里面选取一个 'ie', 'ff', 'opera', 'edge', 'chrome' or 'chrome_headless'." % browser) def open(self, url, title='', timeout=10): u"""打开浏览器,并最大化,判断title是否为预期""" self.driver.get(url) self.driver.maximize_window() try: WebDriverWait(self.driver, timeout, 1).until(EC.title_contains(title)) except TimeoutException: print("open %s title error" % url) except Exception as msg: print("Error:%s" % msg) def find_element(self, locator, timeout=10): u"""定位元素,参数locator为原则""" try: element = WebDriverWait(self.driver, timeout, 1).until(EC.presence_of_element_located(locator)) return element except: print("%s 页面未找到元素 %s" % (self, locator)) def find_elements(self, locator, timeout=10): u"""定位一组元素""" elements = WebDriverWait(self.driver, timeout, 1).until(EC.presence_of_all_elements_located(locator)) return elements def element_wait(self, by, value, secs=5): """ 等待元素显示 """ try: if by == "id": WebDriverWait(self.driver, secs, 1).until(EC.presence_of_element_located((By.ID, value))) elif by == "name": WebDriverWait(self.driver, secs, 1).until(EC.presence_of_element_located((By.NAME, value))) elif by == "class": WebDriverWait(self.driver, secs, 1).until(EC.presence_of_element_located((By.CLASS_NAME, value))) elif by == "link_text": WebDriverWait(self.driver, secs, 1).until(EC.presence_of_element_located((By.LINK_TEXT, value))) elif by == "xpath": WebDriverWait(self.driver, secs, 1).until(EC.presence_of_element_located((By.XPATH, value))) elif by == "css": WebDriverWait(self.driver, secs, 1).until(EC.presence_of_element_located((By.CSS_SELECTOR, value))) else: raise NoSuchElementException( "找不到元素,请检查语法或元素") except TimeoutException: print("查找元素超时请检查元素") def get_element(self, css): """ 判断元素定位方式,并返回元素 """ if "=>" not in css: by = "css" # 如果是css的格式是#aaa,所以在此加入判断如果不包含=>就默认是css传给上面的element_wait判断元素是否存在 value = css # wait element. self.element_wait(by, css) else: by = css.split("=>")[0] value = css.split("=>")[1] if by == "" or value == "": raise NameError( "语法错误,参考: 'id=>kw 或 xpath=>//*[@id='kw'].") self.element_wait(by, value) if by == "id": element = self.driver.find_element(By.ID, value) elif by == "name": element = self.driver.find_element(By.NAME, value) elif by == "class": element = self.driver.find_element(By.CLASS_NAME, value) elif by == "link_text": element = self.driver.find_element(By.LINK_TEXT, value) elif by == "xpath": element = self.driver.find_element(By.XPATH, value) # 如果是xpath要以此格式传入xpath=>//*[@id='su'] elif by == "css": element = self.driver.find_element(By.CSS_SELECTOR, value) else: raise NameError( "Please enter the correct targeting elements,'id','name','class','link_text','xpath','css'.") return element def get_elements(self, css): """ 判断元素定位方式,并返回元素 """ if "=>" not in css: by = "css" # 如果是css的格式是#aaa,所以在此加入判断如果不包含=>就默认是css传给上面的element_wait判断元素是否存在 value = css # wait element. self.element_wait(by, css) else: by = css.split("=>")[0] value = css.split("=>")[1] if by == "" or value == "": raise NameError( "语法错误,参考: 'id=>kw 或 xpath=>//*[@id='kw'].") self.element_wait(by, value) if by == "id": element = self.driver.find_elements(By.ID, value) elif by == "name": element = self.driver.find_elements(By.NAME, value) elif by == "class": element = self.driver.find_elements(By.CLASS_NAME, value) elif by == "link_text": element = self.driver.find_elements(By.LINK_TEXT, value) elif by == "xpath": element = self.driver.find_elements(By.XPATH, value) # 如果是xpath要以此格式传入xpath=>//*[@id='su'] elif by == "css": element = self.driver.find_elements(By.CSS_SELECTOR, value) else: raise NameError( "Please enter the correct targeting elements,'id','name','class','link_text','xpath','css'.") return element def click(self, locator): u"""封装点击操作""" element = self.find_element(locator) element.click() def send_key(self, locator, text): u"""发送文本后清除内容""" element = self.find_element(locator) element.clear() element.send_keys(text) def is_text_in_element(self, text, locator, timeout=10): u"""判断是否定位到元素""" try: result = WebDriverWait(self.driver, timeout, 1).until(EC.text_to_be_present_in_element(locator, text)) except TimeoutException: print u"元素未定位到:" + str(locator) return False else: return result def is_title(self, title, timeout=10): u"""判断title完全相等""" result = WebDriverWait(self.driver, timeout, 1).until(EC.title_is(title)) return result def is_title_contains(self, title, timeout=10): u"""判断是否包含title""" result = WebDriverWait(self.driver, timeout, 1).until(EC.title_contains(title)) return result def is_select(self, locator, timeout=10): u"""判断元素是否被选中""" result = WebDriverWait(self.driver, timeout, 1).until(EC.element_located_to_be_selected(locator)) return result def is_select_be(self, locator, timeout=10, selected=True): u"""判断元素的状态""" return WebDriverWait(self.driver, timeout, 1).until(EC.element_located_selection_state_to_be(locator, selected)) def is_alert_present(self, timeout=10): u"""判断页面有无alert弹出框,有alert返回alert,无alert返回FALSE""" try: return WebDriverWait(self.driver, timeout, 1).until(EC.alert_is_present()) except: print "No Alert Present" def is_visibility(self, locator, timeout=10): u"""判断元素是否可见,可见返回本身,不可见返回FALSE""" return WebDriverWait(self.driver, timeout, 1).until(EC.visibility_of_element_located(locator)) def is_invisibility(self, locator, timeout=10): u"""判断元素是否可见,不可见,未找到元素返回True""" return WebDriverWait(self.driver, timeout, 1).until(EC.invisibility_of_element_located(locator)) def is_clickable(self, locator, timeout=10): u"""判断元素是否可以点击,可以点击返回本身,不可点击返回FALSE""" return WebDriverWait(self.driver, timeout, 1).until(EC.element_to_be_clickable(locator)) def is_located(self, locator, timeout=10): u"""判断元素是否定位到(元素不一定是可见),如果定位到返回Element,未定位到返回FALSE""" return WebDriverWait(self.driver, timeout, 1).until(EC.presence_of_element_located(locator)) def move_is_element(self, locator): u"""鼠标悬停操作""" element = self.find_element(locator) ActionChains(self.driver).move_to_element(element).perform() def back(self): u"""返回到旧的窗口""" self.driver.back() def forward(self): u"""前进到新窗口""" self.driver.forward() def close(self): u"""关闭窗口""" self.driver.close() def quit(self): u"""关闭driver和所有窗口""" self.driver.quit() def get_title(self): u"""获取当前窗口的title""" return self.driver.title def get_netloc(self): u"""获取当前窗口的title""" res = urlparse(self.driver.current_url) return res.scheme + "://" + res.netloc def is_netloc(self,url: str) -> bool: res = urlparse(url) if res.netloc == "": return True return False def get_current_url(self): u"""获取当前页面url""" return self.driver.current_url def get_text(self, locator): u"""获取文本内容""" return self.find_element(locator).text def get_browser_log_level(self): u"""获取浏览器错误日志级别""" lists = self.driver.get_log('browser') list_value = [] if lists.__len__() != 0: for dicts in lists: for key, value in dicts.items(): list_value.append(value) if 'SEVERE' in list_value: return "SEVERE" elif 'WARNING' in list_value: return "WARNING" return "SUCCESS" def get_attribute(self, locator, name): u"""获取属性""" return self.find_element(locator).get_attribute(name) def js_execute(self, js): u"""执行js""" return self.driver.execute_script(js) def js_fours_element(self, locator): u"""聚焦元素""" element = self.find_element(locator) self.driver.execute_script("arguments[0].scrollIntoView();", element) def js_scroll_top(self): u"""滑动到页面顶部""" js = "window.scrollTo(0,0)" self.driver.execute_script(js) def js_scroll_end(self): u"""滑动到页面底部""" js = "window.scrollTo(0, document.body.scrollHeight)" self.driver.execute_script(js) def select_by_index(self, locator, index): u"""通过所有index,0开始,定位元素""" element = self.find_element(locator) Select(element).select_by_index(index) def select_by_value(self, locator, value): u"""通过value定位元素""" element = self.find_element(locator) Select(element).select_by_value(value) def select_by_text(self, locator, text): u"""通过text定位元素""" element = self.find_element(locator) Select(element).select_by_visible_text(text) def F5(self): """ 刷新当前页面. 用法: driver.F5() """ self.driver.refresh() def open_new_window(self, css): """ 打开新窗口并切换到新打开的窗口. 用法: 传入一个点击后会跳转的元素 driver.open_new_window("link_text=>注册") """ original_window = self.driver.current_window_handle el = self.get_element(css) el.click() all_handles = self.driver.window_handles for handle in all_handles: if handle != original_window: self.driver.switch_to.window(handle) def get_verify_code(self, locator): u"""获取图片验证码""" # 验证码图片保存地址 screenImg = "D:/image/verifyCode.png" # 浏览器页面截图 self.driver.get_screenshot_as_file(screenImg) # 定位验证码大小 location = self.find_element(locator).location size = self.find_element(locator).size left = location['x'] top = location['y'] right = location['x'] + size['width'] bottom = location['y'] + size['height'] # 从文件读取截图,截取验证码位置再次保存 img = Image.open(screenImg).crop((left, top, right, bottom)) img.convert('L') # 转换模式:L|RGB img = ImageEnhance.Contrast(img) # 增加对比度 img = img.enhance(2.0) # 增加饱和度 img.save(screenImg) # 再次读取验证码 img = Image.open(screenImg) time.sleep(1) code = pytesseract.image_to_string(img) return code def open_tab(self): u"""打开新选项卡并切换到新选项卡""" self.driver.switch_to.new_window('tab') def open_window(self): u"""打开一个新窗口并切换到新窗口""" self.driver.switch_to.new_window('window') def switch_tab_or_window(self,original_window:any): u"""切换回旧选项卡或窗口""" self.driver.switch_to.window(original_window) if __name__ == '__main__': driver = BrowserHelper("chrome"); # 检查是否处理反爬 driver.open("https://bot.sannysoft.com/");</pre><!--autointro--><!--93-->
2022-03-17
11
0
0
技术分享
CefSharp 处理js默认弹窗
<p>新建JsDialogHandler并继承IJsDialogHandler</p><pre class="brush:c#;toolbar:false">public class JsDialogHandler : IJsDialogHandler { public bool OnJSDialog(IWebBrowser browserControl, IBrowser browser, string originUrl, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage) { //处理js默认弹窗 callback.Continue(true); return true; } public void OnResetDialogState(IWebBrowser browserControl, IBrowser browser) { } public void OnDialogClosed(IWebBrowser browserControl, IBrowser browser) { } public bool OnBeforeUnloadDialog(IWebBrowser chromiumWebBrowser, IBrowser browser, string messageText, bool isReload, IJsDialogCallback callback) { callback.Continue(true); return true; } }</pre><!--autointro--><!--92-->
2022-03-14
4
0
0
技术分享
1
2
3
4
5
...
10