Tenho tentado descobrir como obter o "form:"
valor de uma tag html que se pareça com:
window.__webpack_public_path__='https://renderer-assets.helloWorld.com/';
window.__webpack_nonce__='ca0aa826f043cfc50cc24f6ae5a2fb4a';
window.rendererAssets='["https://renderer-assets.helloWorld.com/vendors~attachment~form-container.0ca60599ecb1b55e02bf.js","https://renderer-assets.helloWorld.com/vendors~libphonenumber~submission.7a28f3a3fe6660429a73.js","https://renderer-assets.helloWorld.com/country-data.62e9eca111db492e793d.js","https://renderer-assets.helloWorld.com/form-container.c34f13ff7b2a95addd81.js","https://renderer-assets.helloWorld.com/renderer.c8aaed3fb2c5d344f80d.js","https://renderer-assets.helloWorld.com/submission.a2f19d1069d330fd0866.js","https://renderer-assets.helloWorld.com/vendors~form-container.9853dbb220cd33f30c2f.js"]';
window.rendererData= {
scriptSrc: 'https://renderer-assets.helloworld.com/renderer.c8aaed3fb2c5d344f80d.js',
rootDomNode: 'root',
form: {
"id":"Z3PvTW",
"title":"TESTING",
"theme": {
"id":"xwizbR",
"font":"Oswald",
"name":"Plain Blue (copy)",
"colors": {
"question": "#3D3D3D", "answer": "#000000", "button": "#000000", "background": "#FFFFFF"
}
,
"has_transparent_button":false,
"visibility":"private"
}
,
"workspace": {
"href": "https:\u002F\u002Fapi.helloWorld.com\u002Fworkspaces\u002FnutqqY"
}
,
"settings": {
"is_public":true,
"is_trial":false,
"language":"en",
"progress_bar":"proportion",
"show_progress_bar":true,
"show_helloWorld_branding":true,
"meta": {
"allow_indexing": false
}
}
,
"welcome_screens":[ {
"ref":"a13820db-af60-40eb-823d-86cf0f20299b",
"title":"TESTING VALUES",
"properties": {
"show_button": true, "button_text": "Start"
}
}
],
"thankyou_screens":[ {
"ref":"default_tys",
"title":"Done! Your information was sent perfectly.",
"properties": {
"show_button": false, "share_icons": false
}
}
],
"fields":[ {
"id":"kxWycKljdtBq",
"title":"FIRST NAME",
"ref":"27f403f7-8c5b-4e18-b19d-1501e8f137ee",
"validations": {
"required": true
}
,
"type":"short_text"
},
{
"id":"WEXCnZ7EAFjN",
"title":"LAST NAME",
"ref":"a6bf6d83-ee37-4870-b6c5-779822290cde",
"validations": {
"required": true
}
,
"type":"short_text"
}
],
"_links": {
"display": "https:\u002F\u002Fautosnkr.helloWorld.com\u002Fto\u002FZ3PvTW"
}
}
,
trackingInfo: {
"segmentKey": "9at6spGDYXelHDdz4r0cP73b3wV1f0ri", "accountId": 12587347, "accountLimitName": "Essentials", "userId": 12586030
}
Meu objetivo aqui é ser capaz de obter todo o formulário: valor em um json.loads, onde mais tarde posso modificá-lo da maneira que desejo, mas antes preciso ser capaz de obter o form:
valor e o que tentei fazer é o seguinte:
regexTest = re.compile(r'form:\((.*?)\);', re.DOTALL)
data = regexTest.findall(response.text)
que acabou de voltar []
Minha pergunta é: como posso obter todo o form:
valor json em um getAllForm = json.loads(...)
?
match = re.search(r"form: ({(\s+.*){1,}\})", response.text).group(1)
print(match)
Saída:
{
"id":"Z3PvTW",
"title":"TESTING",
"theme": {
"id":"xwizbR",
"font":"Oswald",
"name":"Plain Blue (copy)",
"colors": {
"question": "#3D3D3D", "answer": "#000000", "button": "#000000", "background": "#FFFFFF"
}
,
"has_transparent_button":false,
"visibility":"private"
}
,
"workspace": {
"href": "https://api.helloWorld.com/workspaces/nutqqY"
}
,
"settings": {
"is_public":true,
"is_trial":false,
"language":"en",
"progress_bar":"proportion",
"show_progress_bar":true,
"show_helloWorld_branding":true,
"meta": {
"allow_indexing": false
}
}
,
"welcome_screens":[ {
"ref":"a13820db-af60-40eb-823d-86cf0f20299b",
"title":"TESTING VALUES",
"properties": {
"show_button": true, "button_text": "Start"
}
}
],
"thankyou_screens":[ {
"ref":"default_tys",
"title":"Done! Your information was sent perfectly.",
"properties": {
"show_button": false, "share_icons": false
}
}
],
"fields":[ {
"id":"kxWycKljdtBq",
"title":"FIRST NAME",
"ref":"27f403f7-8c5b-4e18-b19d-1501e8f137ee",
"validations": {
"required": true
}
,
"type":"short_text"
},
{
"id":"WEXCnZ7EAFjN",
"title":"LAST NAME",
"ref":"a6bf6d83-ee37-4870-b6c5-779822290cde",
"validations": {
"required": true
}
,
"type":"short_text"
}
],
"_links": {
"display": "https://autosnkr.helloWorld.com/to/Z3PvTW"
}
}
,
trackingInfo: {
"segmentKey": "9at6spGDYXelHDdz4r0cP73b3wV1f0ri", "accountId": 12587347, "accountLimitName": "Essentials", "userId": 12586030
}
Agora, sobre como carregar seu JSONP
dicionário em um JSON
dicionário válido .
Verifique o key
que é trackingInfo
, na verdade está faltando trackingInfo
ser como "trackingInfo"
. Portanto, você precisa citá-lo, pois isso contará como uma duplicata. Por favor, verifique essa resposta
Este artigo é coletado da Internet.
Se houver alguma infração, entre em [email protected] Delete.
deixe-me dizer algumas palavras