我正在尝试使用来自 node js API 的 mandrill 发送邮件。
只要我的“下载链接”没有“危险”字符,例如:“/”和“?”,我就成功发送了以下内容
发送以下内容,但“链接”无处可循:
var downloadLink =(encodeURIComponent('itms-services://c')
var text = [
"We are excited to send you a version of our app",
"You can download it here: <a href=\""+downloadLink+"\">link</a> thats it.",
].join('<br>')
console.log(text)
var message = {
"html": text,
"subject": "New App!",
"from_email": "Hello@d.com",
"from_name": "D Guys",
"to": [{
"email": mail,
//"name": "Recipient Name",
"type": "to"
}],
"headers": {
"Reply-To": "message.reply@example.com"
},
"important": false,
"track_opens": true,
"track_clicks": true,
"auto_text": null,
"auto_html": false,
"inline_css": null,
"url_strip_qs": …Run Code Online (Sandbox Code Playgroud) 我试图在嵌套数组中找到一条记录,修改它,然后投影它.
假设我有以下集合:
{
"_id" : ObjectId("56558dfc45a06f51decb4ab7"),
"arr" : [
{
"cond" : 1.0000000000000000,
"upd" : 2.0000000000000000
},
{
"cond" : 2.0000000000000000,
"upd" : 3.0000000000000000
},
{
"cond" : 4.0000000000000000,
"upd" : 5.0000000000000000
},
{
"cond" : 6.0000000000000000,
"upd" : 7.0000000000000000
},
{
"cond" : 8.0000000000000000,
"upd" : 9.0000000000000000
}
]
}
Run Code Online (Sandbox Code Playgroud)
我想找到"cond = 4"的记录,将其更新为"upd = 55"并返回记录.
我尝试过以下查询:
db.tests.findAndModify({
query:{
"arr": {"$elemMatch": {"cond":4}}
},
update: {
"$set": {"arr.$": {"cond": 4, "upd": 55, "new": true}}
},
fields: {"arr.$":1}
})
Run Code Online (Sandbox Code Playgroud)
它执行更新很好,但我收到以下结果:
{
"_id" …Run Code Online (Sandbox Code Playgroud) 我正在尝试用 python 解析传入的电子邮件。我收到的电子邮件部分是文本,部分是 HTML。我想获取 HTML 部分并在 HTML 中找到一个表格。
我尝试使用 beautifulsoup。但是当尝试下一个代码时,bs 只获取第一个 "" 部分,而不是所有 HTML 部分:
# connecting to the gmail imap server
m = imaplib.IMAP4_SSL("imap.gmail.com")
m.login(user,pwd)
# use m.list() to get all the mailboxes, "INBOX" to get only inbox
m.select("INBOX")
resp, items = m.search(None, '(UNSEEN)') # you could filter using the IMAP rules here (check http://www.example-code.com/csharp/imap-search-critera.asp)
items = items[0].split() # getting the mails id
for emailid in items:
# getting the mail content
resp, data = m.fetch(emailid, '(UID BODY[TEXT])')
text …Run Code Online (Sandbox Code Playgroud) 我正在使用“预”“保存”中间件为“用户”文档创建相应的“ userObjects”文档。
所以有users收藏和userObjects。当user插入新userObjects文件时,也应该插入一个文件。
我正在尝试使用“ pre”中间件,就像这样:
//before inserting a new user
Users.pre('save', function(next) {
var UserObjects = db.model('userObjects');
userObjectsIns = new UserObjects({
'userID': this._id,
'myObjects':[],
});
userObjectsIns.save( function(err) {
if (err) console.log("ERROR while saving userObjectsIns: " + err);
next()
})
});
Run Code Online (Sandbox Code Playgroud)
明显的问题是db不存在。如何从此pre中间件中访问“ userObjects”集合?