我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用xml.etree.cElementTree()。
def propfind(self,s,u, headers=None): print("[*] Sending PROPFIND request...") headers = s.headers if 'Depth' not in headers.keys(): headers.update({'Depth': 'infinity'}) r = s.request('PROPFIND', u, headers=headers) if r.status_code == 301: url = urlparse(r.headers['location']) return self.propfind(s,url.path) if r.status_code == 200 or r.status_code == 207: print("[*] Listing received. Parsing XML. Depending on the size this might take a minute...") soup = bs(r.text, 'xml') return [r.status_code, soup] if r.status_code == 403: #trying again with depth 1 headers.update({'Depth': '1'}) print("[!] 403 Forbidden status code returned. Adjusting Depth header...") return self.propfind(s,u,headers)