我有一个程序需要读取电子邮件并验证它们是否来自本月,然后再继续。
我通过以下代码获取电子邮件信息
import email
import smtplib
import imaplib
mail = imaplib.IMAP4_SSL('redacted', 993)
mail.login(username, bytes(password).decode('utf-8')) #password is bytes that have been decrypted
msg_data2 = [] #My template allows for multiple email data to be appended
mailbox_data = mail.list()
mail.select('INBOX', readonly=True)
result, msg_ids = mail.search(None, f'(SEARCH CRITERIA REDACTED)')
lister = msg_ids[0].split()
most_recent = lister[-1]
result2, msg_data = mail.fetch(most_recent, '(RFC822)')
msg_data2.append(msg_data)
raw = email.message_from_bytes(msg_data[0][1])
Run Code Online (Sandbox Code Playgroud)
从这里,我可以从我的电子邮件中获取符合搜索条件的附件,以前,供应商会根据其工作运行的月份正确命名文件。现在有些不是,所以我试图检查电子邮件发送或接收的日期。
我知道如何通过git-crypt加密存储库中的文件:
echo "*.crypt.* filter=git-crypt diff=git-crypt" > .gitattributes
echo "supersecret info" > somethingTo.crypt.txt
git add .gitattributes somethingTo.crypt.txt
git crypt status # somethingTo.crypt.txt results encrypted
git commit
git push
Run Code Online (Sandbox Code Playgroud)
我知道如何使用git-lfs存储文件(在自托管的 GitLab 上;在项目设置中启用 LFS):
git lfs track somethingTo.crypt.txt
git add .gitattributes # updated LFS rule for tracked file
git commit
git push
Run Code Online (Sandbox Code Playgroud)
...但是,如何在同一个文件上使用它们呢?
即使在用于存储在 LFS 上的过滤器之前.gitattributes有用于加密的git-filter,该文件也不会被加密(报告“未加密”)。LFS 未跟踪的所有其他文件均已正确加密。git crypt status | grep somethingTo*.crypt.*
我想问题在于我somethingTo.crypt.txt现在只是存储库中的引用对象,而不是实际的(加密的)文件。但我希望(感谢 s git-filter)文件在被推送到LFS Store之前会被过滤/加密。 …
我尝试通过http://weixin.sogou.com抓取包含关键词的微信公众号
\n但我发现我必须使用两次 ActionChains(driver).move_to_element(nextpage).click().perform()\xef\xbc\x8cit 仍然可以工作,并转到下一页!
谁能告诉我原因以及如何解决!谢谢你!
\n源代码如下,抱歉注释是中文的。
\n# coding=utf-8\nimport time\nfrom selenium import webdriver\nfrom selenium.webdriver import ActionChains\nfrom selenium.webdriver.support.ui import WebDriverWait\nfrom selenium.webdriver.support import expected_conditions as EC\n\nkey = u"\xe6\xb1\x9f\xe5\x8d\x97\xe5\xa4\xa7\xe5\xad\xa6" #\xe6\x90\x9c\xe7\xb4\xa2\xe7\x9a\x84\xe5\x85\xb3\xe9\x94\xae\xe8\xaf\x8d\ndriver = webdriver.Chrome()\ndriver.get("http://weixin.sogou.com/")\nassert u\'\xe6\x90\x9c\xe7\x8b\x97\xe5\xbe\xae\xe4\xbf\xa1\' in driver.title\nelem = driver.find_element_by_id("upquery")\nelem.clear()\nelem.send_keys(key)\nbutton = driver.find_element_by_class_name("swz2") #\xe6\x90\x9c\xe7\xb4\xa2\xe5\x85\xac\xe4\xbc\x97\xe5\x8f\xb7\nbutton.click()\nWebDriverWait(driver,10).until(\n EC.title_contains(key)\n)\ncount = 0\nwhile True:\n for i in range(10):\n try:\n wechat_name = driver.find_element_by_xpath("//*[@id=\\"sogou_vr_11002301_box_{}\\"]/div[2]/h3".format(i)).text\n print wechat_name\n wechat_id = driver.find_element_by_xpath("//*[@id=\\"sogou_vr_11002301_box_{}\\"]/div[2]/h4/span/label".format(i)).text\n print wechat_id\n wechat_intro = driver.find_element_by_xpath("//*[@id=\\"sogou_vr_11002301_box_{}\\"]/div[2]/p[1]/span[2]".format(i)).text\n print wechat_intro\n print "*************************"\n count += 1\n except:\n pass\n try:\n nextpage = driver.find_element_by_xpath("//*[@id=\\"sogou_next\\"]") #\xe4\xb8\x8b\xe4\xb8\x80\xe9\xa1\xb5\xe7\x9a\x84\xe6\x8c\x89\xe9\x92\xae\n actions …Run Code Online (Sandbox Code Playgroud) 我正在尝试集成nlohmann中的 json c++ 库,同时只需将 'single_include' 文件复制到与我的 main.cpp 文件相同的目录。根据集成说明
json.hpp 是 single_include/nlohmann 中的单个必需文件或在此处发布。你需要添加
#include <nlohmann/json.hpp>
// for convenience
using json = nlohmann::json;
Run Code Online (Sandbox Code Playgroud)
但由于某种原因,编译器认为那里不存在这样的文件,而且我不知道我可以采取什么不同的措施来使这项工作正常进行。
我收到的完整错误:
main.cpp:2:10: fatal error: json.hpp: No such file or directory
#include <json.hpp>
^~~~~~~~~~
compilation terminated.
Run Code Online (Sandbox Code Playgroud)
(我猜测,由于 json.hpp 文件就在 main.cpp 文件旁边,因此我不应该编写它,#include <nlohmann/json.hpp>尽管它是按照集成说明中的方式编写的,对吧?)
*这是我在 VS Code 中的项目目前的样子
我正在寻找 json 文件中所有可能的 json 路径的列表 - 可以推荐任何一个吗?
例如:如果输入低于
{
"_id":{
"$oid":""
},
"aa":false,
"bb":false,
"source":"",
"email":"",
"createdAt":{
"$date":""
},
"updatedAt":{
"$date":""
},
"cc":"",
"vv":"",
"metadata":{
"vv":"",
"xx":[{}]
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
obj
obj._id
obj._id.$oid
obj.aa
obj.bb
obj.source
obj.email
obj.createdAt
obj.createdAt.$date
obj.updatedAt
obj.updatedAt.$date
obj.cc
obj.vv
obj.metadata
obj.metadata.vv
obj.metadata.xx
obj.metadata.xx[0]
Run Code Online (Sandbox Code Playgroud)
我基本都是在找 python 版本: https: //www.convertjson.com/json-path-list.htm
我想构建一个通用解决方案,如果有任何 json 文件 - 它将是模式生成的单个值(即换行符分隔的 json 中的一行)有什么建议吗?
我正在使用服务帐户连接到我个人 Google 帐户中的共享云端硬盘。Google Drive API 始终返回错误,指出未找到共享云端硬盘。我尝试了这两个:
共享驱动器的链接采用以下格式:https://drive.google.com/drive/folders/xyz ,我假设driveId是链接的最后一部分,xyz?或者这是文件夹ID?如果是这样,我如何找到driveId?
// load the service account credentials
data, err := ioutil.ReadFile("service-account.json")
if err != nil {
log.Fatal("failed to read json file")
}
// parse the credentials file
conf, err := google.JWTConfigFromJSON(data, drive.DriveReadonlyScope)
if err != nil {
log.Fatal("failed to parse json file")
}
apiKeyBytes, err := ioutil.ReadFile("api-key.txt")
API_KEY := string(apiKeyBytes)
DRIVE_ID := "1dpl28_lhR1myDL2Y2gYKLRX1gNRlWdFm"
// send the GET request with all the parameters
client := conf.Client(context.Background())
parameters := "?key=" + API_KEY …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 .apk 在设备上运行 apk 文件flutter install。显示以下错误
Error: ADB exited with exit code 1
Performing Streamed Install
adb: failed to install F:\...\build\app\outputs\flutter-apk\app.apk: Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES:Failed to collect certificates from /data/app/vmdl619719557.tmp/base.apk: Attempt to get length of null array]
Install failed
Run Code Online (Sandbox Code Playgroud)
如何领取证书?
YouTube 最近推出了句柄功能,他们为用户提供了 youtube.com/@xxx 类型的用户名,当访问这些 URL 时会显示用户的频道,但我在 API 存储库中找不到任何文档或参考。
如何从 YouTube 用户的句柄中提取频道 ID?
我正在尝试使用 google api v3 从频道获取一些 youtube 视频数据。
\n当我在浏览器中运行该网址时,我得到的信息看起来不错。\nhttps://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCBYyJBCtCvgqA4NwtoPMwpQ&maxResults=10&order=date&type=video&key={MYAPIKEY}
{\n "kind": "youtube#searchListResponse",\n "etag": "lP1l3Vk-JQNUN9moIFDXVlQt9uY",\n "nextPageToken": "CAoQAA",\n "regionCode": "NL",\n "pageInfo": {\n "totalResults": 4109,\n "resultsPerPage": 10\n },\n "items": [\n {\n "kind": "youtube#searchResult",\n "etag": "DIARyKavv5X4EEGZzoIYKd2hzGY",\n "id": {\n "kind": "youtube#video",\n "videoId": "N54TzfCbJOU"\n },\n "snippet": {\n "publishedAt": "2022-11-22T16:00:07Z",\n "channelId": "UCBYyJBCtCvgqA4NwtoPMwpQ",\n "title": "The Wild Project #171 | \xc2\xbfEnga\xc3\xb1aron a Jordi?, Qatar rid\xc3\xadculo inaugural, Desastre con Ley del S\xc3\xad es S\xc3\xad",\n "description": "Como cada semana, nueva tertulia en The Wild Project, comentando las noticias m\xc3\xa1s …Run Code Online (Sandbox Code Playgroud) 我不断收到以下错误:
git commit -sam "blah blah blah"
fatal: either user.signingkey or gpg.ssh.defaultKeyCommand needs to be configured
Run Code Online (Sandbox Code Playgroud)
我刚刚完全更新了 Git,试图解决这个问题,所以它完全是最新的,然后我成功地将所有常用配置添加到现在在 Git Bash 中运行的新版本中。我反复访问 Github 的 SSH 密钥生成器并一一按照说明进行操作。毕竟,我仍然收到此错误。
我无法在本地计算机上的任何地方(Git Bash、终端、GitKraken;我什至崩溃并尝试了 Github Desktop)进行提交,更不用说签名、带注释的提交了,这是我的习惯。我从我的 Github 帐户中删除了过期的密钥。我不知道还能做什么。
python ×3
git ×2
json ×2
youtube ×2
axios ×1
c++ ×1
dart ×1
email ×1
encryption ×1
flutter ×1
git-bash ×1
git-crypt ×1
git-filter ×1
git-lfs ×1
github ×1
go ×1
google-api ×1
json-query ×1
jsonpath ×1
node.js ×1
ssh-keys ×1
youtube-api ×1