Esempio n. 1
0
 def run(self):
     response = self.get_room()
     # print(response.json())
     b64_font = base64encode(json.dumps(response.json()))
     html_content = base64decode(self.font_js.call('parser', b64_font))
     # html_content=response.json()['html'] 直接使用返回的html,价格不对。
     self.parser(html_content)
     with open('xiecheng.html', 'w', encoding='utf-8') as fw:
         html_content = '''<html><head><meta charset="UTF-8"></head><body>{}</body></html>'''.format(
             html_content)
         fw.write(html_content)
Esempio n. 2
0
 def __decorator(*args, **kwargs):
     eleven_js = fun(*args, **kwargs)
     try:
         b64_eleven_js = base64encode(eleven_js)
         b64_url = base64encode(self.url)
         url = 'http://127.0.0.1:3000/get_eleven'
         response = requests.post(url,
                                  data={
                                      'text': b64_eleven_js,
                                      'url': b64_url
                                  })
         return base64decode(response.text)
     except Exception as e:
         msg = '%s' % e
         # print(msg)
         if 'navigator' in msg:
             raise Exception('ip 被封了,请更换ip或稍后重试')
         raise e