Exemplo n.º 1
0
 def get_page(self):
     url = str(self.main_url + PAGE_GET1[1]).format(
         slug=convert_page_title_to_slug(title=self.__dict__.get("title")))
     response = requests.get(url, params=self.__dict__, headers=HEADERS)
     # print(response.json())
     if response.status_code == 200:
         json_data = response.json()
         ID = json_data["id"]
         url = str(self._main_url + PAGE_GET[1]).format(
             slug=convert_page_title_to_slug(
                 title=self.__dict__.get("title")),
             id=self.__dict__.get("id"))
         print(url)
         response = requests.get(url, params=self.__dict__, headers=HEADERS)
         print(response)
     if response.status_code == 200:
         return response.json()
Exemplo n.º 2
0
 def delete_page(self):
     url = str(self.main_url + PAGE_GET1[1]).format(
         slug=convert_page_title_to_slug(title=self.__dict__.get("title")))
     response = requests.get(url, params=params)
     if response.status_code == 200:
         json_data = response.json()
         ID = json_data["id"]
         url = str(self.main_url + PAGE_DELETE[1]).format(id=ID)
         response = requests.delete(url,
                                    params=self.__dict__,
                                    headers=HEADERS)
         if response.status_code == 200:
             return "success"
     return "Failed"
Exemplo n.º 3
0
 def update_page(self):
     # url=str(self.main_url+PAGE_GET[1]).format(id=self.__dict__.get("id"))
     url = str(self.main_url + PAGE_GET1[1]).format(
         slug=convert_page_title_to_slug(title=self.__dict__.get("title")))
     response = requests.get(url, params=self.__dict__, headers=HEADERS)
     # print(response.json())
     if response.status_code == 200:
         json_data = response.json()
         ID = json_data["id"]
         url = str(self.main_url + PAGE_UPDATE[1]).format(
             slug=json_data["post_stream"]["posts"][0]["topic_slug"],
             id=json_data["post_stream"]["posts"][0]["topic_id"])
         if "new_page_title" in self.__dict__:
             self.__dict__.update(
                 {"title": self.__dict__.get("new_page_title")})
         response = requests.put(url, params=self.__dict__, headers=HEADERS)
         # print(response.json())
         if response.status_code == 200:
             return response.json()
     return "Failed"