博客
代码人生:编织技术与生活的博客之旅
永久关闭 WPS 热点、云服务
群里大佬的方法
【江湖人称鸟哥】职业菜鸟 2019/2/25 14:19:53
干掉服务
【江湖人称鸟哥】职业菜鸟 2019/2/25 14:19:57
干掉计划任务
【江湖人称鸟哥】职业菜鸟 2019/2/25 14:20:13
他自带配置 关掉 自动更新 热点推荐啥的
【江湖人称鸟哥】职业菜鸟
图片 1.png
【江湖人称鸟哥】职业菜鸟 2019/2/25 14:20:38
这四个 dll 跟我一样 加个 _
【江湖人称鸟哥】职业菜鸟 2019/2/25 14:20:48
修改之前 先结束 wps 进程
【江湖人称鸟哥】职业菜鸟 2019/2/25 14:20:54
重启 桌面
【江湖人称鸟哥】职业菜鸟 2019/2/25 14:21:02
因为 dll 是注入到 桌面里
- 重启 桌面 win10 没有 Explorer.exe 进程 直接结束 Windows 资源管理器 然后点文件 - 运行新任务 - explorer.exe
网上大佬的方法
每次即使关闭在 任务管理器 中杀死了 wps 热点 wps 云服务等应用不久又会自启,故以下提供永久关闭热点和云服务的方法:
新建一个新的文件(如 txt)并修改成下列文件的名称(后缀一定要修改成。exe),然后覆盖原文件(也可以删除后以同名空文件替换):
1.
WPS Office\…\…\…\ office6\ wpscenter.exe
WPS Office\…\…\…\ office6\ wpscloudlaunch.exe
WPS Office\…\…\…\ office6\ wpscloudsvr.exe
2.
WPS Office\…\…\…\ wtoolex\ wpsnotify.exe
WPS Office\…\…\…\ wtoolex\ wpsupdate.exe
【注】由于 WPS 版本不同,故由主目录索引的深度和目录名称不同,故以“\…\…\…\”代替,我的目录如下图: 这里写图片描述
永久关闭 WPS 初始登陆界面
每次第一次使用 wps 时,都会进入登陆界面,十分卡,以下提供永久关闭初始登陆界面,直接进入文档的方法:
新建一个新的文件(如 txt)并修改成下列文件的名称(后缀一定要修改成。exe),然后覆盖 原文件(也可以删除后以同名空文件替换):
WPS Office\…\…\ ksolaunch.exe
WPS Office\…\…\ wpscloudsvr.exe
【注】由于 WPS 版本不同,故由主目录索引的深度和目录名称不同,故以“\…\…\”代替,该目录为上述目录的上一层,我的目录如下图
用 pycharm 装包出现 pycharm The repository located at pypi douban com is not a
pycharm The repository located at pypi.douban.com is not a trusted or secure
首先在 window 的文件夹窗口输入 : %APPDATA%
然后在底下新建 pip 文件夹,然后到 pip 文件夹里面去新建个 pip.ini, 然后再里面输入内容 [global] timeout = 6000 index-url = http://pypi.douban.com/simple trusted-host = pypi.douban.com
作者:摘星辰 Li 链接:https://www.zhihu.com/question/38341743/answer/128985546 来源:知乎
编程兴趣小组招人
lz18届毕业生一枚,工作有段时间了,计科专业。 上班的时候有很多想法,但没有时间实现。所以组个纯网络的兴趣小组,想把想法变现。
社团性质:
- 纯网络兴趣小组(也就是没有工作室啥的,靠自己)
- 纯公益社团(项目公益,不向社员收费同时也不赚钱,有能力可以靠自己接case)
- python语言向(因为lz只会py编程语言,所以只能给这个支持)
小组成员事物内容:
- 学习编程(偏python,因为lz只能给这方面的指导。。。)
- 实现各种各样的idea(流程一般是:提出想法,大家讨论可行性,组队,实现想法)
小组需要:
- 对编程有兴趣的人(估摸着应该靠自学,编程没兴趣学不下去的)
- 有一定的经济基础(自己的电脑得跑得起编辑器把,租个服务器或买个树莓派啥的,但不会有小组收钱的行为)
- 有时间(课程不紧,闲暇时间比较多)
- 能自己写总结(分享型小组嘛)
加分项
- 有一定编程基础
- 计算机专业大二大三
- 有一定的英语能力(编程,英语还是很重要的)
相信有些人觉得在学校里学的东西出来难找工作,我觉得做些开源项目会对以后找ITl类工作or实习有帮助,不过也不绝对,还是得靠自己努力。
Q群号: 870632533 欢迎转给身边人
编程方式
- 穷举编程
- ccv编程
- 百度编程
- 谷歌编程
- gayhub编程
- guess编程
- no think
- 群友编程
- 小黄鸭调试法(Rubber Duck Debugging)
- 询问式撸代码
只需要 抛出 一个需求 代码大神来解决
网易云消息推送歌曲收集
项目介绍
通过Chrome与selenium 将网易云私信中歌曲放到一个歌单中,方便实时收听新歌。 我们可以直接用已登录的Chrome(保存有网易云网站登录态),模拟用户操作,收藏新歌。
关键代码
- 初始化selenium
def init_driver():
executable_path = "chromedriver"
if not os.path.exists("chromedriver.exe"): # 无驱则需要下载
# 本地项目 复制驱动
_path = os.path.abspath(__file__)
if not "crawler_set" in _path:
root_path = _path[:_path.index("crawler_set") + len("crawler_set")]
executable_path = os.path.join(root_path, "driver", "chromedriver.exe")
else: # 单个文件 下载驱动
url = "https://raw.githubusercontent.com/AngusWG/crawler_set/master/driver/chromedriver.exe"
proxies = {
"http": "socks5://127.0.0.1:1080",
"https": "socks5://127.0.0.1:1080"
}
r = requests.get(url, proxies=proxies)
with open("chromedriver.exe", "wb") as code:
content_size = int(r.headers['content-length']) # 内容体总大小
for data in tqdm(iterable=r.iter_content(1024), total=content_size, unit="k", desc="下载驱动"):
code.write(data)
user_cookies = "".join([os.path.expanduser('~'), r"\AppData\Local\Google\Chrome\User Data"])
option = webdriver.ChromeOptions()
option.add_argument("--user-data-dir={}".format(user_cookies)) # 设置成用户自己的数据目录
try:
driver = webdriver.Chrome(executable_path, options=option)
driver.implicitly_wait(5)
return driver
except WebDriverException:
print("请先关掉所有的Chrome")
exit(-2)
- 收藏歌曲
def save_song(url):
print("[{}] start".format(url), end=" ")
driver.get(url)
driver.switch_to.frame("contentFrame")
title = driver.find_element_by_xpath('//div[contains(@class, "tit")]').text
for word in shielding_words:
if word in title:
print("{} 因 {} 已忽略".format(title, word))
return
driver.find_element_by_xpath('//*[contains(text(), "收藏")]').click()
driver.find_element_by_xpath('//*[contains(text(), "{}")]'.format(song_dir)).click()
print(title)
全部代码
#!/usr/bin/python3
# encoding: utf-8
# @Time : 2019/12/19 9:36
# @author : zza
# @Email : 740713651@qq.com
# @File : 将网易云的私信音乐整理.py
"""
该脚本会保存每天新私信里最后几首歌曲到tmp_save_dir
1.在Chrome上登录自己的网易云帐号t
2.创建tmp_save_dir
然后运行脚本
"""
import os
import requests
from selenium import webdriver
from selenium.common.exceptions import WebDriverException, NoSuchElementException
from tqdm import tqdm
song_dir = "tmp_save_dir"
# 屏蔽关键词
shielding_words = ['伴奏']
def init_driver():
executable_path = "chromedriver"
if not os.path.exists("chromedriver.exe"): # 无驱则需要下载
# 本地项目 复制驱动
_path = os.path.abspath(__file__)
if not "crawler_set" in _path:
root_path = _path[:_path.index("crawler_set") + len("crawler_set")]
executable_path = os.path.join(root_path, "driver", "chromedriver.exe")
else: # 单个文件 下载驱动
url = "https://raw.githubusercontent.com/AngusWG/crawler_set/master/driver/chromedriver.exe"
proxies = {
"http": "socks5://127.0.0.1:1080",
"https": "socks5://127.0.0.1:1080"
}
r = requests.get(url, proxies=proxies)
with open("chromedriver.exe", "wb") as code:
content_size = int(r.headers['content-length']) # 内容体总大小
for data in tqdm(iterable=r.iter_content(1024), total=content_size, unit="k", desc="下载驱动"):
code.write(data)
user_cookies = "".join([os.path.expanduser('~'), r"\AppData\Local\Google\Chrome\User Data"])
option = webdriver.ChromeOptions()
option.add_argument("--user-data-dir={}".format(user_cookies)) # 设置成用户自己的数据目录
try:
driver = webdriver.Chrome(executable_path, options=option)
driver.implicitly_wait(5)
return driver
except WebDriverException:
print("请先关掉所有的Chrome")
exit(-2)
def get_private_detail():
# 点击私信后
driver.get("https://music.163.com/#/msg/m/private")
driver.switch_to.frame("contentFrame")
new_msg_items = driver.find_elements_by_xpath('//i[@class="u-bub"]/b[@class="f-alpha"]/..//parent::*//a')
private_detail_url_dict = dict()
for i in new_msg_items:
_, singer_id = i.get_attribute("href").split("?")
uri = "https://music.163.com/#/msg/m/private_detail?" + singer_id
msg_num = int(i.find_element_by_xpath("../i/em").text)
private_detail_url_dict[uri] = msg_num
return private_detail_url_dict
def get_song_url_from_album_set(url):
song_set = set()
# 歌曲页面保存
driver.get(url)
driver.switch_to.frame("contentFrame")
url_list = driver.find_elements_by_xpath('//a[contains(@href, "/song?id")]')
for item in url_list:
if "伴奏" in item.text:
break
_, song_id = item.get_attribute("href").split("?id=")
song_set.add("https://music.163.com/#/song?id=" + song_id)
song_name = item.find_element_by_xpath("./b").get_attribute("title")
print(song_name, end=" ")
return song_set
def get_song_url_from_private_detail(url, msg_num):
album_set = set()
song_set = set()
# 歌曲页面保存
driver.get(url)
driver.switch_to.frame("contentFrame")
url_list = driver.find_elements_by_xpath('//div[contains(@class,"itemleft")]')[-msg_num:]
for item in url_list:
try:
i = item.find_element_by_xpath(
'.//a[contains(@href,"album?id") or contains(@href, "song?id")]').get_attribute("href")
_, _id = i.split("?id=")
if "song?id" in i:
song_set.add("https://music.163.com/#/song?id=" + _id)
else: # "album?id"
album_set.add("https://music.163.com/#/album?id=" + _id)
except NoSuchElementException:
pass
for album_url in album_set:
song_set.update(get_song_url_from_album_set(album_url))
return song_set
def save_song(url):
print("[{}] start".format(url), end=" ")
driver.get(url)
driver.switch_to.frame("contentFrame")
title = driver.find_element_by_xpath('//div[contains(@class, "tit")]').text
for word in shielding_words:
if word in title:
print("{} 因 {} 已忽略".format(title, word))
return
driver.find_element_by_xpath('//*[contains(text(), "收藏")]').click()
driver.find_element_by_xpath('//*[contains(text(), "{}")]'.format(song_dir)).click()
print(title)
driver = init_driver()
if not os.path.exists("tmp.txt"):
# 获取私信用户列表
private_detail_url_dict = get_private_detail()
print("private_detail_url_set len={}".format(len(private_detail_url_dict)))
# 获取歌曲id
song_url_set = set()
for private_detail_url, msg_num in private_detail_url_dict.items():
song_url_set.update(get_song_url_from_private_detail(private_detail_url, msg_num))
print("song_url_set len={}".format(len(song_url_set)))
with open("tmp.txt", "w", encoding="utf8") as f:
f.write("\n".join(song_url_set))
else:
with open("tmp.txt", "r", encoding="utf8") as f:
data = f.read()
song_url_set = data.split("\n") if data else []
# 保存歌曲
for song_url in song_url_set:
save_song(song_url)
os.remove("tmp.txt")
driver.close()
解决 Flask-SQLAlchemy 2006 MySQL server has gone away 问题
配置信息
- python3 3.6
- Flask-SQLAlchemy 2.3.2
- win10
报错
-----> [2018-07-16 17:22:42,041] [ERROR] [base.py<131>-base.run_job]: Job "auto_rollback.<locals>.wrapper (trigger: interval[0:30:00], next run at: 2018-07-16 17:52:42 CST)" raised an exception
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
context)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 411, in _query
rowcount = self._do_query(q)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 374, in _do_query
db.query(q)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 277, in query
_mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (2006, 'MySQL server has gone away')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/apscheduler/executors/base.py", line 125, in run_job
retval = job.func(*job.args, **job.kwargs)
File "/home/zza/eth_crawler/crawler_script/utils.py", line 28, in wrapper
raise err
File "/home/zza/eth_crawler/crawler_script/utils.py", line 24, in wrapper
return func(*args, **kwargs)
File "/home/zza/eth_crawler/crawler_script/token_tracker.py", line 240, in update
db_address = db.session.query(Token.contract_address).filter(None == Token.total_supply).all()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2773, in all
return list(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2925, in __iter__
return self._execute_and_instances(context)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2948, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 948, in execute
return meth(self, multiparams, params)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
compiled_sql, distilled_params
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
context)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
exc_info
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
context)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 411, in _query
rowcount = self._do_query(q)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 374, in _do_query
db.query(q)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 277, in query
_mysql.connection.query(self, query)
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (2006, 'MySQL server has gone away') [SQL: 'SELECT token.contract_address AS token_contract_address \nFROM token \nWHERE token.total_supply IS NULL'] (Background on this error at: http://sqlalche.me/e/e3q8)
已使用解决方案
出错后需要 rollback,为了后续程序能运行,给每个涉及 sql 语句的函数用了装饰器
def auto_rollback(func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as err:
db.session.rollback()
log.error(err)
raise err
return wrapper
- 治标不治本系列
把 SQLALCHEMY_POOL_RECYCLE 设成一个较小的数
app.config['SQLALCHEMY_POOL_SIZE'] = 128 # 线程池大小
app.config['SQLALCHEMY_POOL_TIMEOUT'] = 90 # 超时时间
app.config['SQLALCHEMY_POOL_RECYCLE'] = 3 # 空闲连接自动回收时间
app.config['SQLALCHEMY_MAX_OVERFLOW'] = 128 # 控制在连接池达到最大值后可以创建的连接数。