考虑一下我:
req = requests.get('https://www.draftkings.com/lobby/getlivecontests?sport=NBA')
data = req.json()
contests = []
for ids in data:
contests.append(ids['id'])
driver = webdriver.Chrome() # Optional argument, if not specified will search path.
driver.get('https://www.draftkings.com/account/sitelogin/false?returnurl=%2Flobby');
time.sleep(2) # Let DK Load!
search_box = driver.find_element_by_name('username')
search_box.send_keys('username')
search_box2 = driver.find_element_by_name('password')
search_box2.send_keys('password')
submit_button = driver.find_element_by_xpath('//*[@id="react-mobile-home"]/section/section[2]/div[3]/button/span')
submit_button.click()
time.sleep(2) # Let Page Load, If not it will go to Account!
for id in contests:
element = driver.find_element_by_css_selector('a')
script1 = "arguments[0].setAttribute('download',arguments[1]);"
driver.execute_script(script1, element, str(id) + '.pdf')
script2 = "arguments[0].setAttribute('href',arguments[1]);"
driver.execute_script(script2, element, 'https://www.draftkings.com/contest/exportfullstandingscsv/' + str(id))
time.sleep(1)
element.click()
time.sleep(3)
问题1:
我想迭代它,有点像这样(我需要键和值):
let users = {
"user1": { "fname" : "fname1", "lname" : "lname1"},
"user2": { "fname" : "fname2", "lname" : "lname2"},
"user3": { "fname" : "fname3", "lname" : "lname3"}
};
问题2:
我想从“用户”中删除项目,例如:
users.map(function(key, value) {
//use key,value here...
}
}
如何在打字稿中执行此操作?或者还有其他更好的解决方案......
答案 0 :(得分:0)
这不是特定于TypeScript的问题,而是更多的JavaScript问题。
如果要迭代对象键,可以使用Object.keys来实现此目的。
Object.keys(users).map((key, value) =>
// Do something with
users[key]
)