假设我们有一个数据库:
from selenium import webdriver
import time
driver=webdriver.Firefox()
driver.get('https://www.instagram.com/accounts/login/')
time.sleep(2)
user_name=driver.find_element_by_xpath('//*[@id="react-root"]/section/main/div/article/div/div[1]/div/form/div[1]/div/input')
user_name.send_keys('user_name')
password=driver.find_element_by_xpath('//*[@id="react-root"]/section/main/div/article/div/div[1]/div/form/div[2]/div/input')
password.send_keys('pa$$')
driver.find_element_by_xpath('//*[@id="react-root"]/section/main/div/article/div/div[1]/div/form/span[1]/button').click()
如何使用recipe_key检索辣椒值?我检查了angularfire2的文档,它说使用了快照更改但是使用这个代码我只能得到" Recipes"。我想我需要再去一层?
Recipes
recipe_key(some uniq key generated when data pushed)
ingredients:pepper
答案 0 :(得分:0)
文档是正确的,您应该使用快照更改,以便从有效负载对象中获取密钥属性。
查看您的代码我相信您忘记将密钥添加到object()
AngularFireDatabase
方法
const recipeKey = '<your-push-key>';
afDb.object(`/recipes/${recipeKey}`).snapshotChanges().map(action => {
const $key = action.payload.key;
const data = { $key, ...action.payload.val() };
return data;
}).subscribe(item => console.log(item.$key));
如果要使用$ key属性检索列表,可以使用此方法。
afDb.list(`/recipes`).snapshotChanges().map(actions => {
return actions.map(action => {
const $key = action.payload.key;
const data = { $key, ...action.payload.val() };
return data;
});
}).subscribe(items => console.log(items));