Exemplo n.º 1
0
 def search_by_isbn(self, isbn):
     """
         isbn搜索的结果可以被缓存
     """
     url = self.isbn_url.format(isbn)
     result = Http.get(url)
     self.__fill_single(result)
Exemplo n.º 2
0
 def search_by_keyword(self, keyword, page):
     """
         keyword不缓存,意义不大
     """
     page = int(page)
     url = self.keyword_url.format(keyword, self.per_page, self.per_page * (page - 1))
     result = Http.get(url)
     self.__fill_collection(result)
Exemplo n.º 3
0
 def getLocation(self,Latlng):
     url=self.url1.format(Latlng)
     result=Http.get(url)
     self._fill(result)
     url1=self.url2.format(Latlng)
     result1=Http.getPicture(url1) 
     self._fill(result)
     self.view=result1
Exemplo n.º 4
0
 def get_openid(self, code):
     url = self.url.format(current_app.config['APP_ID'], current_app.config['SECRET'], code)
     # print(url)
     result = Http.get(url)
     print(result)
     try:
         self.fill(result)
     except KeyError:
         print("Invalid response form WeChat Server")
Exemplo n.º 5
0
 def get_book_from_api(cls, isbn, persistence=False):
     url = cls.isbn_url.format(isbn)
     # result = Http(url).get()
     result = Http(url).get()
     if result.get('code') == 2000:
         return {}, 'from_api'
     if persistence:
         book_model = MySQL.persistence_douban(result)
         return book_model, 'from_mysql'
     return result, 'from_api'
Exemplo n.º 6
0
 def search_by_query(cls, query):
     url = cls.url.format(query)
     result = Http.get(url)
     return result
Exemplo n.º 7
0
 def search_by_keyword(cls, keyword, page=1):
     url = cls.keyword_url.format(keyword, current_app.config['PER_PAGE'],
                                  cls.calculate_start(page))
     result = Http.get(url)
     return result
Exemplo n.º 8
0
 def search_by_isbn(cls, isbn):
     url = cls.isbn_url.format(isbn)
     result = Http.get(url)
     return result
Exemplo n.º 9
0
 def search_by_keyword(self, keyword, page):
     page = int(page)
     url = self.keyword_url.format(keyword, self.per_page,
                                   self.per_page * (page - 1))
     result = Http.get(url)
     self._fill_connection(result)
Exemplo n.º 10
0
 def search_by_isbn(self, isbn):
     url = self.isbn_url.format(isbn)
     result = Http.get(url)
     self.__fill_single(result)