import Ali1688Uploader from './Ali1688Uploader' import Ali1688Searcher from './Ali1688Searcher' export class Ali1688Crawler { uploader: Ali1688Uploader searcher: Ali1688Searcher constructor(options?) { this.uploader = new Ali1688Uploader(options) this.searcher = new Ali1688Searcher(options) } async uploadAndSearch(fileBuffer) { const uploadResult = await this.uploader.upload(fileBuffer) if (uploadResult && uploadResult.data) { const imageId = uploadResult.data.imageId const searchResult = await this.searcher.imageSearchResult({ imageId }) return searchResult } return null } async addToCart() { } image_search_url(imageId) { const url = 'https://s.1688.com/youyuan/index.htm' const params = new URLSearchParams({ tab: 'imageSearch', imageId, imageIdList: imageId, }) return `${url}?${params.toString()}` } }