def get_apikey(self, header=None):
"""
Retrieve and sets a new apikey.
:param header: a custom header for retrieving the apikey.
"""
self.header = copy.deepcopy(self.DEFAULTHEADER)
if header is None:
header = self.APIKEYHEADER
response = requests.get('http://www.gutefrage.net/frage_hinzufuegen', headers=header)
self.apikey = re.search(
"key: '([^']+)'",
html.document_fromstring(response.text).xpath('//script[1]')[0].text
).group(1)
self.header['X-Api-Key'] = self.apikey
return self.apikey
#TODO: rework this function eventually
评论列表
文章目录