def search_by_isbn(self, isbn): """ isbn搜索的结果可以被缓存 """ url = self.isbn_url.format(isbn) result = Http.get(url) self.__fill_single(result) return result
def search_by_keyword(self, keyword, page=1): # 根据 keyword 请求 API url = self.keyword_url.format( keyword, current_app.config['PER_PAGE'], # 从配置文件导入每页的信息条数 self.calculate_start(page)) result = Http.get(url) self.__fill_collection(result)
def get(self): wx_result = Http.get(self.wx_login_url) if not wx_result: raise Exception() else: if 'errcode' in wx_result.keys(): self.__process_login_error(wx_result) else: return wx_result
def search_by_isbn(self, isbn): url = self.isbn_url.format(isbn) result = Http.get(url) # 返回result为json格式的dict # book = query_from_mysql(isbn) # if book: # return book # else: # save(result) self.__fill_single(result)
def search_by_keyword(self, keyword, page): """ keyword不缓存,意义不大 """ page = int(page) url = self.keyword_url.format(keyword, current_app.config['PER_PAGE'], self.calculate_start(page)) result = Http.get(url) self.__fill_collection(result) return result
def search_by_isbn(self, isbn): """ isbn搜索 :param isbn:书籍isbn参数 :return: 书籍信息对象 """ url = self.isbn_url.format(isbn) result = Http.get(url) # print(result) self.__fill_single(result)
def search_by_key(self, keyword, page=1): """ self 可以取到类变量,访问变量的顺序 :param keyword: :param page: :return: """ url = self.keyword_url.format(keyword, current_app.config['PER_PAGE'], self.calculate_start(page)) result = Http.get(url) self.__fill_collection(result)
def search_by_isbn(self, isbn): isbn_url = self.isbn_url.format(isbn) result = Http.get(isbn_url) # 从数据库查询是否有该书,如果没有,执行保存数据库,有的话跳过 book = Book() res = Book.query.filter_by(isbn=result['isbn']).first() if res is None: book.set_attrs(result) db.session.add(book) db.session.commit() self.__fill_single(result)
def search_by_isbn(self, isbn): """ 没有存储数据的话,如果返回回去,则是伪面向对象, 我们应该把数据存储到对象 定义初始化变量值,并将其返回的值赋给对象本身 将最终数据存储到对象本身, 但是如果存储的过多,会太具体化,影响我们通过其他途径获取数据的方式 :param isbn: :return: """ url = self.isbn_url.format(isbn) result = Http.get(url) self.__fill_single(result)
def search_by_isbn(self, q): isbn = self.isbn_url.format(q) result = Http.get(str(isbn)) self.__isbn(result)
def search_by_keyword(self, keyword, page=1): url = self.keyword_url.format(keyword, current_app.config["PER_PAGE"], self.calculate_start(page)) result = Http.get(url) self.search_by_keyword(result)
def search_by_isbn(cls, isbn): url = cls.isbn_url.format(isbn) result = Http.get(url) # 返回result为json格式的dict return result
def search_by_keyword(cls, keyword, page): keyword_url = cls.keyword_url.format(keyword, current_app.config['PER_PAGE'], cls.calculate_start(page)) result = Http.get(keyword_url) return result
def search_by_isbn(self, isbn_no: str): url = Book.isbn_url.format(isbn_no) result = Http.get(url) self.__single(result)
def search_by_isbn(self, isbn): url = self.isbn_url.format(isbn) result = Http.get(url) self.__fill_single(result)
def search_by_keyword(cls, keyword, page=1): # url = cls.isbn_url.format(keyword, cls.per_page, (page-1)*cls.per_page) url = cls.isbn_url.format(keyword, current_app.config['PER_PAGE'], cls.calculate_start(page)) result = Http.get(url) return result
def search_by_keyword(self, q, page=1): #key = self.keyword_url.format(q, current_app.config['PER_PAGE'], self.calculate_start(page)) key = self.keyword_url.format(q) result = Http.get(key) self.__keyword(result)
def search_by_keyword(self, keyword, page=1): # url = cls.isbn_url.format(keyword, cls.per_page, (page-1)*cls.per_page) url = self.isbn_url.format(keyword, current_app.config['PER_PAGE'], self.calculate_start(page)) result = Http.get(url) self.__fill_collection(result)
def search_by_keyword(self, keyword, page=1): url = self.keyword_url.format(keyword, current_app.config.get('PER_PAGE'), self.calulate_start(page)) result = Http.get(url) self.__fill_collection(result)
def search_by_key(self, keyword, page): key_url = self.key_url.format(keyword, current_app.config['PER_PAGE'], self.calculate_start(page)) result = Http.get(key_url) self.__fill_collection(result)
def get_by_keyword(cls, keyword): url = cls.keyword_url.format(keyword) result = Http.get(url) return result
def search_by_keyword(self, keyword, page=1): url = self.keyword_url.format(keyword, current_app.config['PER_PAGE'], self.__get_start_page(page)) result = Http.get(url) self.__fill_collection(result)
def get_by_isbn(cls, isbn): url = cls.isbn_url.format(isbn) result = Http.get(url) return result
def search_by_keyword(self, keyword: str, page: int = 1): url = self.keyword_url.format(keyword, current_app.config.get('PER_PAGE'), Book.__get_start(page)) result = Http.get(url) self.__collections(result)
def search_by_isbn(cls, isbn): isbn_url = cls.isbn_url.format(isbn) result = Http.get(isbn_url) return result