MCPcopy Create free account
hub / github.com/aitjcize/cppman / urlopen

Function urlopen

cppman/util.py:112–119  ·  view source on GitHub ↗

A wrapper around urllib.request.urlopen() which adds custom headers

(url, *args, **kwargs)

Source from the content-addressed store, hash-verified

110 return str(bs4.BeautifulSoup(data, "html5lib"))
111
112def urlopen(url, *args, **kwargs):
113 """A wrapper around urllib.request.urlopen() which adds custom headers"""
114 if isinstance(url, urllib.request.Request):
115 req = url
116 else:
117 req = urllib.request.Request(url)
118 req.add_header('User-Agent', _USER_AGENT)
119 return urllib.request.urlopen(req, *args, **kwargs)
120
121def build_opener(*args, **kwargs):
122 """A wrapper around urllib.request.build_opener() which adds custom headers"""

Callers 4

func_testFunction · 0.90
testFunction · 0.90
func_testFunction · 0.90
testFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected