MCPcopy
hub / github.com/pyload/pyload / load

Method load

module/plugins/internal/Plugin.py:160–254  ·  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 accordin

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

Source from the content-addressed store, hash-verified

158 raise Fail(decode(msg)) # @TODO: Remove `decode` in 0.4.10
159
160 def load(self, url, get={}, post={}, ref=True, cookies=True, just_header=False, decode=True,
161 multipart=False, redirect=True, req=None):
162 """
163 Load content at url and returns it
164
165 :param url:
166 :param get:
167 :param post:
168 :param ref:
169 :param cookies:
170 :param just_header: If True only the header will be retrieved and returned as dict
171 :param decode: Wether to decode the output according to http header, should be True in most cases
172 :return: Loaded content
173 """
174 if self.pyload.debug:
175 self.log_debug("LOAD URL " + url,
176 *["%s=%s" % (key, value) for key, value in locals().items()
177 if key not in ("self", "url", "_[1]")])
178
179 url = fixurl(url, unquote=True) #: Recheck in 0.4.10
180
181 if req is False:
182 req = get_request()
183 req.setOption("timeout", 60) # @TODO: Remove in 0.4.10
184
185 elif not req:
186 req = self.req
187
188 #@TODO: Move to network in 0.4.10
189 if isinstance(cookies, list):
190 set_cookies(req.cj, cookies)
191
192 http_req = self.req.http if hasattr(self.req, "http") else self.req
193
194 #@TODO: Move to network in 0.4.10
195 if not redirect:
196 # @NOTE: req can be a HTTPRequest or a Browser object
197 http_req.c.setopt(pycurl.FOLLOWLOCATION, 0)
198
199 elif type(redirect) is int:
200 # @NOTE: req can be a HTTPRequest or a Browser object
201 http_req.c.setopt(pycurl.MAXREDIRS, redirect)
202
203 #@TODO: Move to network in 0.4.10
204 if isinstance(ref, basestring):
205 req.lastURL = ref
206
207 html = req.load(
208 url,
209 get,
210 post,
211 bool(ref),
212 bool(cookies),
213 just_header,
214 multipart,
215 decode is True) # @TODO: Fix network multipart in 0.4.10
216
217 #@TODO: Move to network in 0.4.10

Callers

nothing calls this directly

Calls 10

log_debugMethod · 0.95
dump_htmlMethod · 0.95
fixurlFunction · 0.85
set_cookiesFunction · 0.85
parse_html_headerFunction · 0.85
itemsMethod · 0.80
setOptionMethod · 0.80
html_unescapeFunction · 0.70
getConfigValueMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected