मैं urllib वाली साइट पर लॉगिन करता हूं, लेकिन मुझे एक सत्यापन पृष्ठ मिलता है। मुझे समझ नहीं आ रहा है कि बाधा को दूर करने के लिए मुझे सर्वर को क्या उत्तर भेजना है। मुझे लगता है कि मैं समझता हूं कि मुझे एक पोस्ट भेजना है, लेकिन सभी सामग्री भेजकर मुझे वांछित परिणाम नहीं मिलता है। क्या मुझे कुछ खास भेजना चाहिए? चीज़?

अगर कोई मेरी मदद कर सकता है तो मैं बहुत आभारी रहूंगा। धन्यवाद।

लॉग इन करने के बाद मुझे जो विशाल उत्तर मिलता है वह यहां दिया गया है ...

<html>
 <head>
  <title>Working...</title> </head>
   <body> 
    <form method="POST" name="hiddenform" action="https://site.domain.com:443/"> 
     <input type="hidden" name="wa" value="wsignin1.0" /> 
      <input type="hidden" name="wresult" 
       value="&lt;t:RequestSecurityTokenResponse  xmlns:t=&quot; 
       http://schemas.xmlsoap.org/ws/2005/02/trust&quot;>
       &lt;  t:Lifetime>&lt; 
       wsu:Created xmlns:wsu=&quot; 
       http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd&quot;
       >2020-04-04T19:44:03.524Z&lt; 
       /wsu:Created>&lt;  wsu:Expires xmlns:wsu=&quot; 
       http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd&quot;
       >2020-04-04T20:44:03.524Z&lt;    
       /wsu:Expires>&lt;/t:Lifetime>&lt;  wsp:AppliesTo        xmlns:wsp=&quot; 
       http://schemas.xmlsoap.org/ws/2004/09/policy&quot; 
       >&lt;  wsa:EndpointReference xmlns:wsa=&quot;  http://www.w3.org/2005/08/addressing&quot; 
       >&lt;  wsa:Address>https://site.domain.com&lt;  /wsa:Address>&lt;  /wsa:EndpointReference>&lt;  /wsp:AppliesTo>&lt; 
       t:RequestedSecurityToken>&lt;  saml:Assertion MajorVersion=&quot; 
       1&quot;   MinorVersion=&quot;  1&quot;   AssertionID=&quot; 
       _a0230c49-7fed-4469-bf9e-702b63ee7477&quot;   Issuer=&quot;  http://site2.domain.comadfs/services/trust&quot;  
       IssueInstant=&quot;  2020-04-04T19:44:03.524Z&quot;  
       xmlns:saml=&quot;  urn:oasis:names:tc:SAML:1.0:assertion&quot; 
       >&lt;  saml:Conditions NotBefore=&quot;  2020-04-04T19:44:03.524Z&quot;   NotOnOrAfter=&quot; 
       2020-04-04T20:44:03.524Z&quot; 
       >&lt;  saml:AudienceRestrictionCondition>&lt;  saml:Audience>https://site.domain.com&lt;  /saml:Audience>&lt; 
       /saml:AudienceRestrictionCondition>&lt;  /saml:Conditions>&lt; 
       saml:AttributeStatement>&lt;  saml:Subject>&lt; 
       saml:SubjectConfirmation>&lt; 
       saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer&lt; 
       /saml:ConfirmationMethod>&lt;  /saml:SubjectConfirmation>&lt; 
       /saml:Subject>&lt;  saml:Attribute AttributeName=&quot; 
       implicitupn&quot;   AttributeNamespace=&quot; 
       http://schemas.xmlsoap.org/ws/2005/05/identity/claims&quot; 
       >&lt;  saml:AttributeValue>user@site.root.local&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  accountthrottled&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/ws/2017/04/identity/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue b:type=&quot;  tn:boolean&quot;   xmlns:tn=&quot;  http://www.w3.org/2001/XMLSchema&quot;  
       xmlns:b=&quot;  http://www.w3.org/2001/XMLSchema-instance&quot; 
       >false&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute AttributeName=&quot;  familiarlocation&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/ws/2017/04/identity/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue b:type=&quot;  tn:boolean&quot;   xmlns:tn=&quot;  http://www.w3.org/2001/XMLSchema&quot;  
       xmlns:b=&quot;  http://www.w3.org/2001/XMLSchema-instance&quot; 
       >true&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute AttributeName=&quot;  authnmethodsproviders&quot;  
       AttributeNamespace=&quot;  http://schemas.microsoft.com/claims&quot; 
       >&lt;  saml:AttributeValue>FormsAuthentication&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  anchorclaimtype&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/ws/2014/01/identity/claims&quot; 
       >&lt;  saml:AttributeValue>http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname&lt;
       /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  upn&quot;   AttributeNamespace=&quot; 
       http://schemas.xmlsoap.org/ws/2005/05/identity/claims&quot; 
       >&lt;  saml:AttributeValue>user@site.root.local&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  primarygroupsid&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/ws/2008/06/identity/claims&quot; 
       >&lt;  saml:AttributeValue>S-1-5-21-4287071985-2918672672-1443967343-513&lt;
       /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  primarysid&quot;   AttributeNamespace=&quot; 
       http://schemas.microsoft.com/ws/2008/06/identity/claims&quot; 
       >&lt;  saml:AttributeValue>S-1-5-21-4287071985-2918672672-1443967343-48981&lt;
       /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  name&quot;   AttributeNamespace=&quot; 
       http://schemas.xmlsoap.org/ws/2005/05/identity/claims&quot; 
       >&lt;  saml:AttributeValue>Username1&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute AttributeName=&quot; 
       windowsaccountname&quot;   AttributeNamespace=&quot; 
       http://schemas.microsoft.com/ws/2008/06/identity/claims&quot; 
       >
&lt;  saml:AttributeValue>Username1&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute AttributeName=&quot; 
       authnmethodsreferences&quot;   AttributeNamespace=&quot; 
       http://schemas.microsoft.com/claims&quot; 
       >&lt;  saml:AttributeValue>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport&lt;
       /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  groupsid&quot;   AttributeNamespace=&quot; 
       http://schemas.microsoft.com/ws/2008/06/identity/claims&quot; 
       >&lt;  saml:AttributeValue>S-1-5-21-4287071985-2918672672-1443967343-513&lt;
       /saml:AttributeValue>&lt;  saml:AttributeValue>S-1-1-0&lt; 
       /saml:AttributeValue>&lt;  saml:AttributeValue>S-1-5-32-545&lt; 
       /saml:AttributeValue>&lt;  saml:AttributeValue>S-1-5-2&lt; 
       /saml:AttributeValue>&lt;  saml:AttributeValue>S-1-5-11&lt; 
       /saml:AttributeValue>&lt;  saml:AttributeValue>S-1-5-15&lt; 
       /saml:AttributeValue>&lt; 
       saml:AttributeValue>S-1-5-21-4287071985-2918672672-1443967343-13989&lt;
       /saml:AttributeValue>&lt; 
       saml:AttributeValue>S-1-5-21-4287071985-2918672672-1443967343-38388&lt;
       /saml:AttributeValue>&lt; 
       saml:AttributeValue>S-1-5-21-4287071985-2918672672-1443967343-22934&lt;
       /saml:AttributeValue>&lt; 
       saml:AttributeValue>S-1-5-21-4287071985-2918672672-1443967343-11501&lt;
       /saml:AttributeValue>&lt;  saml:AttributeValue>S-1-18-2&lt; 
       /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  x-ms-client-user-agent&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/2012/01/requestcontext/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue>Mozilla/5.0 (X11;   Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99
       Safari/537.36&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt; 
       saml:Attribute AttributeName=&quot; 
       x-ms-endpoint-absolute-path&quot;   AttributeNamespace=&quot; 
       http://schemas.microsoft.com/2012/01/requestcontext/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue>/adfs/ls/&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute AttributeName=&quot; 
       insidecorporatenetwork&quot;   AttributeNamespace=&quot; 
       http://schemas.microsoft.com/ws/2012/01&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue b:type=&quot;  tn:boolean&quot;   xmlns:tn=&quot;  http://www.w3.org/2001/XMLSchema&quot;  
       xmlns:b=&quot;  http://www.w3.org/2001/XMLSchema-instance&quot; 
       >false&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute AttributeName=&quot;  x-ms-proxy&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/2012/01/requestcontext/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue>WAPDMZMR01&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute AttributeName=&quot; 
       client-request-id&quot;   AttributeNamespace=&quot; 
       http://schemas.microsoft.com/2012/01/requestcontext/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue>605e2c74-b033-4ca8-81c4-0380010000ba&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  relyingpartytrustid&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/2012/01/requestcontext/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue>https://site.domain.com&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  x-ms-client-ip&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/2012/01/requestcontext/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue>10.244.3.252&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  x-ms-forwarded-client-ip&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/2012/01/requestcontext/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue>172.16.8.2&lt;  /saml:AttributeValue>&lt;  saml:AttributeValue>85.203.20.10&lt;  /saml:AttributeValue>&lt; 
       /saml:Attribute>&lt;  saml:Attribute AttributeName=&quot; 
       userip&quot;   AttributeNamespace=&quot; 
       http://schemas.microsoft.com/2014/09/requestcontext/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue>85.203.20.10&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt; 
       /saml:AttributeStatement>&lt;  saml:AuthenticationStatement
       AuthenticationMethod=&quot; 
       urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport&quot;
       AuthenticationInstant=&quot;  2020-04-04T19:44:03.430Z&quot; 
       >&lt;  saml:Subject>&lt;  saml:SubjectConfirmation>&lt;  saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer&lt; 
       /saml:ConfirmationMethod>&lt;  /saml:SubjectConfirmation>&lt; 
       /saml:Subject>&lt;  /saml:AuthenticationStatement>&lt;  ds:Signature
       xmlns:ds=&quot;  http://www.w3.org/2000/09/xmldsig#&quot; 
       >&lt;  ds:SignedInfo>&lt;  ds:CanonicalizationMethod Algorithm=&quot;  http://www.w3.org/2001/10/xml-exc-c14n#&quot;   />&lt; 
       ds:SignatureMethod Algorithm=&quot; 
       http://www.w3.org/2001/04/xmldsig-more#rsa-sha256&quot;   />&lt; 
       ds:Reference URI=&quot; 
       #_a0230c49-7fed-4469-bf9e-702b63ee7477&quot; 
       >&lt;  ds:Transforms>&lt;  ds:Transform Algorithm=&quot;  http://www.w3.org/2000/09/xmldsig#enveloped-signature&quot;   />&lt; 
       ds:Transform Algorithm=&quot; 
       http://www.w3.org/2001/10/xml-exc-c14n#&quot;   />&lt; 
       /ds:Transforms>&lt;  ds:DigestMethod Algorithm=&quot; 
       http://www.w3.org/2001/04/xmlenc#sha256&quot;   />&lt; 
       ds:DigestValue>b1c+9bvSmPpFNvScSNJJpTbJ6LwIyo1RCvDVKY8QeuI=&lt; 
       /ds:DigestValue>&lt;  /ds:Reference>&lt;  /ds:SignedInfo>&lt; 
       ds:SignatureValue>LA1dNOW7en/qQ5Z90WZTZ0Asb+BHubYP2MwDdGYh0AjsJMl+YIzC66h8hQfASOThETLlkwCkyOF1bvghWzOB6ZO/GgCgsGaEf8/Ed38zJVis2oFyAJz5Jj9XJ3tHRrpbFQdNEO8NHC8e8QgSiMep1j96rnT7BNiNqpkbCLsC/BB9B/c2RS6tYXRZhKVneXQtZAMjywgd+OH0IiUbbpiBbK2+/X16UhyHUTWzs6CJI7Pv9SQY6rv+PIdAp0iZugOmmufyEuHgHcqjMW9w64HBONSRIwqJ7/blEKGGto1Urp4vxzpMjr7428AZikr4rG/09ublQZ+WEjhwgEZlh/BDUw==&lt;
       /ds:SignatureValue>&lt;  KeyInfo xmlns=&quot; 
       http://www.w3.org/2000/09/xmldsig#&quot; 
       >&lt;  X509Data>&lt;  X509Certificate>MIICzjCCAbagAwIBAgIQI9D9o/iPMbpLE+TnZuC+ITANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDExhBREZTIFNpZ25pbmcgLSBmcy5hdG0uaXQwHhcNMTkxMTE5MjMwOTQ5WhcNMjAxMTE4MjMwOTQ5WjAjMSEwHwYDVQQDExhBREZTIFNpZ25pbmcgLSBmcy5hdG0uaXQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCkFFIK/Cn7t3E5VQ2jII/aH+2oEuK43MgtZp7hOcu431R3aUkXbevBVoOs5t6dOs2She9JL48RwcFeb6T1eiMT3HoYYfXERma4gy0SPQmGed1qtEApVo+Stxt4/V1B125tlpn9/xfpBasHyP/qCQIPSFxfgwRRYTN+cUtN9Wxjuw4m+dIySdk9c9POFvoC9vgB5tTSugWz2x02Cfi+hkDhWnPOaHFPE3V0vUZ3DGpJfiBGQizhnbZqaizjO6yQdWtkisoNX89GEmh6VTexSzlW9GCtDHLOqSjbkfEm8hU8H6kYsicot4ama/9RNcNHBx/kODPilIESuSm0zpyNEfw1AgMBAAEwDQYJKoZIhvcNAQELBQADggEBAD3LajP8S7I0fzl8rYqcmmhwsh6LvCVgigclt2YkFLD6MCJueacBs5NUcMmsiGa5JiY/FC405Iw9S2GhzBjNejDsyZAtplV/IShT6OOAp3GAWTkNDQoGdejbsExeRkFMCMAlLy2Nq1mnB6YwEMo4bHodG+ghQihxgSWQuFePKMuyrlZwvz07PDL56MCjiNrN+i1SHd1XCSwxpB2hY8LYN3EGqezKdyBbyVhAKgXTILPinxf1yciyoazLAg/5bMG33jTf31ijBDmsqbBD9FlDvUGp30uRXkbEUz/YXJC+p3acBmaUL5jGdyrO8dNj6ENYwmHEjlnLAAuBdDr9ly1czJM=&lt;
       /X509Certificate>&lt;  /X509Data>&lt;  /KeyInfo>&lt; 
       /ds:Signature>&lt;  /saml:Assertion>&lt; 
       /t:RequestedSecurityToken>&lt; 
       t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion&lt; 
       /t:TokenType>&lt; 
       t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue&lt; 
       /t:RequestType>&lt; 
       t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey&lt;
       /t:KeyType>&lt;  /t:RequestSecurityTokenResponse>" /><input
       type="hidden" name="wctx" value="rm=0&amp;  id=passive&amp;  ru=%2f"
       /><noscript><p>Script is disabled. Click Submit to continue.</p>
       <input type="submit" value="Submit" /></noscript></form> <script
       language="javascript">window.setTimeout('document.forms[0].submit()',
       0);  </script></body></html>
1
Andriy 11 अप्रैल 2020, 15:13

1 उत्तर

सबसे बढ़िया उत्तर

इस पृष्ठ पर तीन प्रपत्र फ़ील्ड वाला एक प्रपत्र है:

<input type="hidden" name="wa" value="wsignin1.0" /> 
<input type="hidden" name="wresult" value="(encoded XML)" />
<input type="hidden" name="wctx" value="rm=0&amp;  id=passive&amp;  ru=%2f"/>

और वेबसाइट पेज लोड होने के तुरंत बाद उस फॉर्म को पोस्ट करने के लिए एक स्क्रिप्ट का उपयोग करती है:

window.setTimeout('document.forms[0].submit()', 0); 

इसका मतलब है कि आपको वही काम करने की ज़रूरत है।

  1. प्रतिक्रिया HTML से प्रपत्र फ़ील्ड और उनके मान पुनर्प्राप्त करने का तरीका जानें।
  2. पता करें कि पायथन के साथ फ़ॉर्म पोस्ट कैसे करें। urllib के साथ ऐसा करना निश्चित रूप से संभव है, लेकिन एक अधिक विकसित पुस्तकालय जैसे requests यह बहुत आसान है
  3. उन तीन फ़ॉर्म फ़ील्ड और उनके मान जोड़ें और <form> की क्रिया विशेषता में URL को एक POST अनुरोध भेजें।
  4. वेब स्क्रैपिंग लाइब्रेरी scrapy ऐसा करने के लिए एक सुविधा भी प्रदान करता है, जो चरण #1 और #2 को आसान बना देगा।

(कोई कोड नमूना नहीं है, आप ऊपर दी गई जानकारी के साथ इसका पता लगाने में सक्षम होना चाहिए।)

2
Tomalak 11 अप्रैल 2020, 12:30