MCPcopy
hub / github.com/codelucas/newspaper / remove_args

Function remove_args

newspaper/urls.py:38–52  ·  view source on GitHub ↗

Remove all param arguments from a url.

(url, keep_params=(), frags=False)

Source from the content-addressed store, hash-verified

36BAD_DOMAINS = ['amazon', 'doubleclick', 'twitter']
37
38def remove_args(url, keep_params=(), frags=False):
39 """
40 Remove all param arguments from a url.
41 """
42 parsed = urlsplit(url)
43 filtered_query= '&'.join(
44 qry_item for qry_item in parsed.query.split('&')
45 if qry_item.startswith(keep_params)
46 )
47 if frags:
48 frag = parsed[4:]
49 else:
50 frag = ('',)
51
52 return urlunsplit(parsed[:3] + (filtered_query,) + frag)
53
54def redirect_back(url, source_domain):
55 """

Callers

nothing calls this directly

Calls 2

joinMethod · 0.80
splitMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…