MCPcopy Index your code
hub / github.com/pyload/pyload / load

Method load

module/plugins/Plugin.py:399–457  ·  view source on GitHub ↗

Load content at url and returns it :param url: :param get: :param post: :param ref: :param cookies: :param just_header: if True only the header will be retrieved and returned as dict :param decode: Wether to decode the output according to http

(self, url, get={}, post={}, ref=True, cookies=True, just_header=False, decode=False)

Source from the content-addressed store, hash-verified

397
398
399 def load(self, url, get={}, post={}, ref=True, cookies=True, just_header=False, decode=False):
400 """Load content at url and returns it
401
402 :param url:
403 :param get:
404 :param post:
405 :param ref:
406 :param cookies:
407 :param just_header: if True only the header will be retrieved and returned as dict
408 :param decode: Wether to decode the output according to http header, should be True in most cases
409 :return: Loaded content
410 """
411 if self.pyfile.abort: raise Abort
412 #utf8 vs decode -> please use decode attribute in all future plugins
413 if type(url) == unicode: url = str(url)
414
415 res = self.req.load(url, get, post, ref, cookies, just_header, decode=decode)
416
417 if self.core.debug:
418 from inspect import currentframe
419
420 frame = currentframe()
421 if not exists(join("tmp", self.__name__)):
422 makedirs(join("tmp", self.__name__))
423
424 f = open(
425 join("tmp", self.__name__, "%s_line%s.dump.html" % (frame.f_back.f_code.co_name, frame.f_back.f_lineno))
426 , "wb")
427 del frame # delete the frame or it wont be cleaned
428
429 try:
430 tmp = res.encode("utf8")
431 except:
432 tmp = res
433
434 f.write(tmp)
435 f.close()
436
437 if just_header:
438 #parse header
439 header = {"code": self.req.code}
440 for line in res.splitlines():
441 line = line.strip()
442 if not line or ":" not in line: continue
443
444 key, none, value = line.partition(":")
445 key = key.lower().strip()
446 value = value.strip()
447
448 if key in header:
449 if type(header[key]) == list:
450 header[key].append(value)
451 else:
452 header[key] = [header[key], value]
453 else:
454 header[key] = value
455 res = header
456

Callers 3

decryptCaptchaMethod · 0.95
cFunction · 0.45
cFunction · 0.45

Calls 6

existsFunction · 0.85
splitlinesMethod · 0.80
encodeMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected