- 博客(31)
- 资源 (17)
- 收藏
- 关注
原创 使用selenium打开网页并保存cookie至json文件
在编写爬虫,或者模拟浏览器进行一些操作时,如果每次都模拟用户输入账号密码登陆,实现步骤较为复杂,登陆后抓取cookies,在后续操作中使用cookies登陆是一种较为简便的方法。因此,本文使用python3 + chromedriver,帮助完成cookies的抓取。需要安装python3环境,安装selenium和json包,并下载对应版本的chromedriverfrom selenium import webdriverimport json options = webdriver.Chr
2021-05-18 00:14:44 2326
原创 Windows下载TS格式m3u8格式视频下载方法
下载ffmpeg,并配置到环境变量中(或者复制ffmpeg.exe到python等已经在环境变量中的文件夹中)在访问网页前打开F12(或打开F12后刷新网页),进入Network,找***.m3u8格式的资源,右键复制其链接在CMD中使用下述命令回车完成下载:其中https://example.com/linklink.m3u8对应m3u8的资源链接,output_name.mp4为下载合并后得到的mp4文件ffmpeg -i https://example.com/linklink.m3u8 .
2021-04-24 03:00:15 1518 2
原创 覆盖安装windows解决windows权限、文件异常等疑难杂症
最近不知道是因为安装了某些软件还是系统出了问题,在打开资源换利器、组策略等系统组件时,会报出用户账户控制错误:“为了对电脑进行保护,已经阻止此应用。管理员已阻止你运行此应用。有关详细信息,请于管理员联系。”同时观察到详情中的发布者为“未知”,故猜测可能是系统文件损坏或证书、权限出现问题首先尝试更改账户控制UAC,即使更改到最低也没有效果,虽然可以通过修改注册表等方式更彻底地关闭UAC,从而打开设备管理器等系统应用,但是关闭UAC对于系统安全来说也是个隐患,故放弃进而尝试DELL客服提供的方法:右
2020-12-26 14:25:28 1798
原创 python使用装饰器监控函数运行时间
from functools import wrapsimport timedef func_timer(function): @wraps(function) def function_timer(*args, **kwargs): start = time.time() result = function(*args, **kwargs) end = time.time() print ("函数%s总运行时间: %s s" %(function.__nam
2020-12-13 11:10:00 661
原创 JAVA生成特定位数特定内容的随机字符串
public class Utils {public static String j(int length) { int a = 16; String KeyString = "123456789abcdefghijklmnopqrstuvwxyz"; int len = KeyString.length(); StringBuffer sb = new StringBuffer(); for(int i=0;i<a;i++){ sb.appen
2020-12-10 19:24:49 969
原创 Python根据URL地址下载文件并保存至对应目录
Python根据URL地址下载文件并保存至对应目录引言在编程中经常会遇到图片等数据集将图片等数据以URL形式存储在txt文档中,为便于后续的分析,需要将其下载下来,并按照文件夹分类存储。本文以Github中Alexander Kim提供的图片分类数据集为例,下载其提供的图片样本并分类保存Python 3.6.5,Anaconda, VSCode1. 下载数据集文件建立项目文件夹,下载上述...
2020-09-19 16:01:52 70830 5
原创 Photoshop 添加ico图标格式支持
Photoshop原生缺乏对ico图标格式的支持,但是我们可以通过添加组件的形式,导出ico文件,下面介绍方法。首先,打开下述网址下载8bi组件:http://www.telegraphics.com.au/sw/product/ICOFormat根据系统版本选择对应版本的插件,插件支持Mac/Win平台下巨虎所有Photoshop版本下载完成后,解压下载得到的zip压缩包得到.8bi格式(系统不同可能扩展名会有所差异)的文件。进入软件安装目录下的\Required\Plug-ins\File F
2020-08-26 00:23:53 1355
原创 windows 下使用命令快速在cmd或powershell中以管理员权限执行命令
本文通过使用scoop安装sudo实现在windows下实现类似linux系统下的sudo的效果安装Scoop若已安装请跳过此步骤Scoop为windows下非常方便的包管理程序,可以通过类似linux下yum/apt的命令实现软件安装和软件管理。打开powershell并执行下述命令保证本地脚本的执行:set-executionpolicy remotesigned -scope currentuser安装:iex (new-object net.webclient).downl
2020-08-15 15:31:24 3788
原创 Python3随爬虫启动代理池(引用外部Python代码项目并实现多进程并行执行)
最近在写某网站爬虫的过程中,遇到了异常访问封禁IP的问题。而且不只是爬虫访问会触发封禁,网页端一次浏览太多页面也会触发反爬保护。为了解决这个问题,在Github上找到了一个不错的免费IP代理池程序,这个作者通过爬虫爬取了几个免费的IP代理源,并且定期循环对节点进行监测,删除失效代理,将有效代理存储于redis库中。而且,通过向本地特定端口发送请求,即可获取和操作本地IP代理池的代理,配置完成后非常方便。然而,在使用过程中也发现,每次手动启动代理非常麻烦,所以就想在主爬虫进程启动前,先调用该代理池程序,在
2020-08-10 13:09:37 254
原创 Python3使用pipreqs生成requirements.txt
当一个Python完成后,若要在新环境下运行,往往需要重新安装各种包依赖,这就需要记录当前环境下所用到的包、包的版本等,非常麻烦,这里介绍一种方法,可以较为快速便捷地生成requirements.txt文件,在新环境下部署运行时,执行下述命令,即可自动安装所需的对应版本的包依赖。pip install -r requirements.txtrequirements.txt中的内容格式类似:APScheduler==3.2.0werkzeug==0.15.3Flask==1.0requests&
2020-07-24 09:25:59 1986
原创 基于人口普查数据的收入预测模型构建及比较分析(Python数据分析分类器模型实践)
收入是反映人民生活水平和国家经济发展状况的重要指标,改善收入水平,提高生活质量是各国政府和人民共同的奋斗目标。探索收入的影响因素,不仅对国家具有重要意义,对个人提升自我,企业识别目标消费群体也具有重要的参考价值。为了研究年龄、受教育程度、职业等诸多因素对个体收入的影响,本文以UCI Machine Learning Repository网站提供的人口普查数据作为数据样本,遵循CRISP-DM的数据挖掘流程,对数据中可能存在的规律进行探索和分析,构建决策树、Logistic回归、K近邻、线性支持向量机、随机森
2020-07-09 20:40:25 20963 16
原创 Python 比较日期字符串与当前日期的日期差
在Python中经常会需要用到时间比较的情况,如爬取特定一段时间的数据,或比较某一时间值和当前时间的差import datetimedate_str = "2020-07-06" # 以此时间为例interval = datetime.datetime.today() - datetime.datetime.strptime(date_str,"%Y-%m-%d")print('目标日期与当前日期的日期差为:{}天'.format(interval.days))若要比较两个给定日期字符串的日
2020-07-07 10:04:17 3025
原创 Python 8行代码实现input询问键盘输入超时自动跳过选择默认值
在编写Python程序时,经常需要设置临时选择项,如出现异常时询问后续操作,或程序开始执行时询问必要参数等,这时候往往需要用到input或弹窗等方式向用户询问。然而,当程序并不是自己用,或者需要分享给他人的时候,出于稳健性的考虑,我们可能需要为此类输入命令设置超时时间,如询问选择后若5秒内未得到返回值,就选择默认参数,并继续执行后续进程。然而,通过一段时间的搜索,网上提供了不少超时终止的方法,如采取多线程的方法,或使用包eventlet,或者使用signal。经过测试,发现其各自都有一些问题。对于使用
2020-07-06 11:33:22 4674 13
原创 Python3通过简单进程池multiprocessing.Pool实现多进程(学习笔记)
在编写Python程序时,经常需要同时执行多个运算任务或多项工作以实现某些功能和使用计算机的多核提高执行效率,这里介绍一种非常简单的方法实现多进程。这里使用的是multiprocessing提供的Pool方法来实现多进程以下述代码为例:from multiprocessing import Pool # 导入线程池import os, time, random # 导入其他包def long_time_task(name): print('Run task %s (%s)...'
2020-07-04 17:59:16 1338
原创 Macbook Pro Bootcamp 安装触控板驱动mac-precision-touchpad在Windows系统下实现更好的触控板操作
由于很多软件的限制,所以不得不在Windows和MacOS之间进行切换,然而,Windows下虽然Bootcamp提供了触控板的驱动,然而只能实现简单的上下滑动和点击等操作,而且在滑动页面的时候滑动非常不流畅,体验极差。今天无意间发现了一款第三方撰写的驱动,可以较为完美地实现Macbook笔记本在Windows系统下的触控板操作支持,通过在我的2015款Macbook Pro(A1502)进行安装测试,感觉体验很不错,在这里分享给大家。驱动来自于Github上的imbushu,他的项目地址如下:htt
2020-07-02 19:57:05 15495 3
原创 Windows下Anaconda配置conda和pip镜像源,实现快速包安装
配置pip源在用户路径下创建pip文件夹,在pip文件夹中创建pip.ini,文件编码使用默认或(GB2312),输入[global]trusted-host=pypi.doubanio.com #豆瓣源,可以换成其他的源index-url=https://pypi.doubanio.com/simple/ #添加豆瓣源为可信主机,要不然可能报错保存后,下期进行包安装即可自动应用。配置好后的文件路径为%HOME%\pip\pip.ini下面三个pip源速度都还不错,可
2020-07-02 16:14:38 4386
原创 Windows Terminal 使用管理员身份创建标签页
在Windows Terminal里运行指令,经常容易遇到某些操作需要使用管理员权限,但是Terminal却忘记使用管理员权限打开的情况。不仅如此,以管理员权限打开Windows Terminal步骤也比较繁琐(有比较便捷的方法欢迎评论哈),而且打开后所有的标签页都会拥有管理员权限,有一定的安全风险。但是在MacOS或Linux的Terminal中,我们却可以简单使用sudo命令实现从用户身份向管理员身份的转变。那么,Windows下能否实现sudo一样的命令,来快速地对某一个标签页开启管理者权限呢?这里
2020-06-29 18:59:39 14891 17
原创 windows cmd执行命令时卡死 假死,按空格回车方向键等进行键盘操作后恢复
今天在使用you-get下载视频的时候发现,cmd经常动不动就没有反应了,视频下载进度没有变化,速度没有变化,仿佛是凝固了一般,但是在窗口敲击键盘任意按键,按按Enter,按按方向键,cmd命令又会醒过来继续执行,甚至跳出来一堆东西,重启、重新执行依然无法解决问题,遂上网查找解决方案。经过一番测试,也受到http://m.lanhusoft.com/Article/697.html这篇文章的启发,问题出在cmd的设置里面:cmd默认开启了“快速编辑模式”,只要当鼠标点击cmd任何区域时,就自动进入了编
2020-06-24 00:52:49 18206 3
原创 使用MATLAB求解线性规划问题,并输出单纯形表,识别无界解和无穷多最优解情况
本文构建SimplexMax函数,通过构建单纯型表和循环迭代,求解线性规划问题的最优解clc;clear;%% 设置变量,调用函数% 题目参数A = [0 5 1 0 0; 6 2 0 1 0; 1 1 0 0 1];b = [15; 24; 5];c = [2 1 0 0 0];ind = [3 4 5]% 无界解% A = [-2 1 1 0;% ...
2020-03-31 16:44:04 5136
原创 使用MATLAB的solve函数求解线性方程组
使用MATLAB的solve函数求解线性方程组示例定义变量定义方程组使用solve函数进行求解输出求解结果syms a b p k e w; % 定义变量eqns = [b*p - e*k - a == 0, e + k*p + k*w == 0, 2*b*p == a + e*k + b*w]; % 定义规则res = solve(eqns,w,e,p); % 求解re...
2020-03-31 16:29:18 15073
原创 MATLAB 2019 设置自定义字体
老版本的MATLAB安装字体到Windows即可在MATLAB的预设-字体中进行设置,但MATLAB 2019b等较新的版本安装好字体后有时却在MATLAB中找不到对应的字体解决方法:将字体的ttf文件放置到MATLAB安装目录的jre中的font文件夹内,路径如下:C:\Program Files\MATLAB\R2019b\sys\java\jre\win64\jre\lib\fonts...
2019-11-11 21:46:29 4551 2
转载 在windows中把文件上传到远程Linux服务器
1.下载可以从http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html下载pscp,并将其放入windows的system32 文件夹下,这样在dos命令窗口中就能直接调用使用了。2、使用(一)Windows—Linux上传文件:1)、开始→运行→cmd进入到dos模式,输入以下命令:pscp E:\javaWP\ne...
2019-04-24 17:15:51 5629
原创 Python3 Pandas DataFrame 对某一列求和
Pandas DataFrame 对某一列求和在操作pandas的DataFrame的时候,常常会遇到某些列是字符串,某一些列是数值的情况,如果直接使用df_obj.apply(sum)往往会出错使用如下方式即可对其中某一列进行求和dataf_test1['diff'].sum() // diff为要求和的列...
2019-04-24 11:50:05 108609 1
转载 statsmodels.regression.linear_model.RegressionResults
statsmodels.regression.linear_model.RegressionResults*class statsmodels.regression.linear_model.RegressionResults(model, params, normalized_cov_params=None, scale=1.0, cov_type=‘nonrobust’, cov_kwds=...
2019-04-24 10:56:24 3440
原创 利用油猴脚本实现知网搜索自动选择核心期刊
利用知网查询学术期刊默认选择全部期刊,而很多时候我们只希望找到SCI、SSCI等核心期刊,每次都要手动勾选太麻烦,这里利用油猴写一个脚本自动点选想要查询的期刊,省去每次选择的麻烦首先在浏览器中安装油猴插件右键插件按钮选择“选项”打开油猴设置面板点选右上角加号创建新脚本删除原有代码,将下述代码黏贴进去,保存即可// ==UserScript==// @name CNK...
2019-03-18 10:59:46 3078 3
原创 python递归遍历目录和子目录下的所有文件,并将文件目录存入列表
python递归遍历目录和子目录下的所有文件,并将文件目录存入列表本文编写了一个函数,实现递归查找目标目录path和目标目录下的多层子目录下的所有文件,并将所有文件的path 存放于一个list列表中。import osdef get_file(root_path,all_files=[]): ''' 递归函数,遍历该文档目录和子目录下的所有文件,获取其path '...
2019-01-18 17:24:18 10416 2
原创 Servlet实现查询返回json数据
使用Servlet响应浏览器的请求,实现Ajax查询等功能 package servlet;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;import javax.servlet.http...
2019-01-04 15:57:16 11493
原创 测试不同浏览器对HTML5音频视频的支持
使用不同音频视频样本,测试浏览器对不同格式的支持程度。音视频样本下载:https://download.csdn.net/download/weixin_39858881/10306563网页源码:<!doctype html><html><head><meta charset="utf-8"><title>音视...
2019-01-04 14:54:54 982
原创 Mysql 8.0 创建DBCP连接池
DBCP连接池简介 DBCP(DataBase connection pool)数据库连接池是 apache 上的一个Java连接池项目。DBCP通过连接池预先同数据库建立一些连接放在内存中(即连接池中),应用程序需要建立数据库连接时直接到从接池中申请一个连接使用,用完后由连接池回收该连接,从而达到连接复用,减少资源消耗的目的。MySQL 8.0MySQL 8.0以后,对jav...
2019-01-04 14:53:44 3947 1
原创 TOMCAT访问文件目录返回资源列表
尝试访问一个不存在index的文件目录,如localhost:8080/example/,如果返回目录列表,则证明开启,若报错,则需要进入Tomcat的conf目录,对web.xml进行如下编辑:原始代码: <servlet> <servlet-name>default</servlet-name> <ser...
2018-12-29 12:05:16 1333
原创 JAVA-编写循环将一个数组的值赋值给另一数组
package com.Javapractice;// 循环给新数组赋值public class practice3 { public static void main(String args[]){ int a[]={10,20,30,40,50}; //int b[(a.length)]; // 不可以这样声明 //int b[]=
2017-09-24 10:45:35 18005
代码及相关资料—基于人口普查数据的收入预测模型构建及比较分析(Python数据分析分类器模型实践)
2022-07-19
Macbook Bootcamp 触控板Trackpad 驱动 mac-precision-touchpad
2020-07-02
mysql8 DBCP连接池jar依赖
2019-01-04
validator jQuery表单验证插件
2018-07-12
commons-logging-1.2
2018-07-12
commons-collections4-4.1
2018-07-12
Apache commons-pool2-2.5.0
2018-07-12
音频视频格式测试包
2018-03-24
Apache POI 3.17
2017-12-24
深度学习工具包 DeepLearningToolbox
2017-10-15
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人