MCPcopy Create free account
hub / github.com/ActiveState/code / gethtml

Function gethtml

recipes/Python/579107_simplify_webpage/recipe-579107.py:136–146  ·  view source on GitHub ↗
(link)

Source from the content-addressed store, hash-verified

134 return "".join(res)
135
136def gethtml(link):
137 user_agent = "Mozilla/5.0 (Windows NT 6.1; rv:38.0) Gecko/20100101 Firefox/38.0"
138 headers={'user-agent':user_agent}
139 s = requests.Session()
140 try:
141 res = s.get(link,headers=headers).text
142 except requests.exceptions.InvalidSchema:
143 req=urllib2.Request(link,None,headers)
144 r = urllib2.urlopen(req)
145 res = r.read().decode('utf8')
146 return res
147
148def textwindow(url):
149 title = url

Callers 1

textwindowFunction · 0.85

Calls 5

SessionMethod · 0.80
getMethod · 0.45
RequestMethod · 0.45
decodeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected