我正在关注这本书,我很确定我会逐字复制代码.当我复制发布商网站(nostarch.com/ContactUs)上的"联系我们"页面并通过该程序运行时,它会输出所有电话号码但没有电子邮件地址.
我确保代码被正确复制.我认为这可能是打印功能的一个问题,所以我尝试将结果粘贴到文本文件中,电子邮件地址仍然无处可寻.
import pyperclip, re
# email regex
emailRegex = re.compile(r'''(
[a-zA-Z0-9._%+-]+ # username
@ # at symbol
[a-zA-Z0-9.-]+ # domain name
(\.[a-zA-Z]{2-4}) #dot-something
)''', re.VERBOSE)
# find matches in clipboard text
text = str(pyperclip.paste())
matches = []
for groups in phoneRegex.findall(text):
phoneNum = '-'.join([groups[1], groups[3], groups[5]])
if groups[8] != '':
phoneNum += ' x' + groups[8]
matches.append(phoneNum)
for groups in emailRegex.findall(text):
matches.append(groups[0])
# copy results to the clipboard
if len(matches) > 0:
pyperclip.copy('\n'.join(matches))
print ('Copied to clipboard:')
print ('\n'.join(matches)) …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我们的登录页面上设置 WebAuthn。我现在需要使用 来生成公钥navigator.credentials.create()。在 Chrome 上,我不断收到以下错误:Uncaught (in promise) DOMException: The operation either timed out or was not allowed. See: https://www.w3.org/TR/webauthn-2/#sctn-privacy-considerations-client.
这是相关代码:
if (isAvailable) {
// Get challenge from server
fetch("WebAuthn/WebAuthn.ashx", {
method: "POST"
})
.then(res => res.json())
.then(res => {
const publicKeyCredentialCreationOptions = {
challenge: Uint8Array.from(
res.data, c => c.charCodeAt(0)),
rp: {
id: "localhost",
name: "Company Name"
},
authenticatorSelection: {
authenticatorAttachment: "platform",
userVerification: "discouraged"
},
pubKeyCredParams: [{alg: -7, type: "public-key"}],
user: {
id: Uint8Array.from(
"UZSL85T9AFC", c => c.charCodeAt(0)), …Run Code Online (Sandbox Code Playgroud)