![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
Python知识分享
secsafe
这个作者很懒,什么都没留下…
展开
-
selenium无头浏览器配置教程
from selenium import webdriverfrom time import sleep#无头浏览器引入模块from selenium.webdriver.chrome.options import Options#无头浏览器设置chrome_options = Options()chrome_options.add_argument('--headless')chrome_options.add_argument('--disable-gpu')#无头浏览器增加属性op原创 2021-10-26 09:09:57 · 7059 阅读 · 0 评论 -
python邮件发送带附件(可用,可以发送成功)
import smtplibfrom email.mime.text import MIMETextfrom email.mime.multipart import MIMEMultipartfrom email.header import Header# 第三方 SMTP 服务mail_host = "smtp.qq.com" # 设置服务器mail_user = "40***61@qq.com" # 用户名mail_pass = "mbm****hfjmbjij" # 口令sen原创 2021-09-08 08:09:48 · 352 阅读 · 0 评论 -
python生成txt文件
import osdef create_txt(filename): //获取当前文件所在路径 filepath = os.getcwd() print(filepath) file_path = filepath + '\\' + filename + '.txt' print(file_path) #exit() file = open(file_path, 'w') file.close()create_txt('kangkang')原创 2021-09-07 17:30:29 · 3311 阅读 · 0 评论 -
python线程池pool.map的使用
import requestsimport timefrom multiprocessing.dummy import Poolheaders = { 'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36'}urls = [ 'https://sp1.baidu.com/原创 2021-09-07 15:37:48 · 6250 阅读 · 4 评论 -
python检测网址状态是否正常-多线程版本
import urllib.requestimport timeimport threadingopener = urllib.request.build_opener()# opener.addheaders = [('User-agent', 'Mozilla/49.0.2')]file = open(r'urls.txt')lines = file.readlines()def work(): while True: if len(lines) >原创 2021-09-01 11:34:29 · 627 阅读 · 0 评论 -
python遍历json数据方法
python遍历json数据方法代码案例items = { "code": "success", "msg": "成功", "data": [{ "id": 13, "imgurl": "http:\/\/tu.sdgpicpic.cn\/b02dj3542\/12.jpg" }, { "id": 12, "imgurl": "http:\/\/tu.sdgpicpic.cn\/b02dj3530\/11.jpg" }, { "id": 11, "imgurl":原创 2021-09-01 10:51:16 · 16403 阅读 · 2 评论 -
python取网站标题
这里写自定义目录标题直接上代码直接上代码import urllib.requestimport rewebs = ['https://www.网址.cn/','http://www.网址.com/']def get_title(url): try: page = urllib.request.urlopen(url=url) except Exception as e: print(e) else: html = pag原创 2021-09-01 10:42:07 · 300 阅读 · 0 评论 -
python获取网站标题-教程-代码-python web
#!/usr/bin/python#coding=utf-8#urllib2是python自带的模块,在python3.x中被改为urllib.requestimport urllib.requestimport rewebs = ['https://www.baidu.com/','http://www.xxx.com/']def get_title(url): try: page = urllib.request.urlopen(url=url) ex原创 2021-04-23 09:14:28 · 294 阅读 · 1 评论