def save(fileName): titles = [] prices = [] urls = [] for item in items: titles.append(item['title']) prices.append(item['price']) urls.append(item['url']) item_dict = { 'title': titles, 'price': prices, 'URL': urls, } try: df = pd.DataFrame(item_dict) df.to_csv(dt.now().strftime("%Y%m%d_%H%M") + '_' + fileName + '.csv', encoding='utf-8-sig') logger.debug("CSV出力完了") eel.message('CSV保存完了') except Exception as error: error_logger('CSV保存エラー', error)
def save(fileName): try: df = pd.DataFrame(item.item_info) df.to_csv(dt.now().strftime("%Y%m%d_%H%M") + '_' + fileName + '_' + '.csv', encoding='utf-8-sig') logger.debug("CSV出力完了") eel.message('CSV保存完了') except Exception as error: error_logger('CSV保存エラー', error)
def narrow_price_range(price_range): global driver global search try: search.set_price_range(driver, price_range) eel.message('価格範囲絞り込み完了') eel.view_current_url(driver.current_url) except Exception as error: error_logger('価格範囲絞り込みエラー', error) return None
def narrow_category(category_url, isSub=False): global driver global search try: driver.get(category_url) if not isSub: search.get_sub_category(driver) eel.message('カテゴリ絞り込み完了、サブカテゴリを設定しました。') eel.set_sub_category_info(search.sub_categories) else: eel.message('サブカテゴリ絞り込み完了') eel.view_current_url(driver.current_url) except Exception as error: error_logger('カテゴリ絞り込みエラー', error) return None
def fetch(fetchNumber): global item try: current_url = driver.current_url logger.debug(current_url) search_goods.parse_html(current_url) soup = search_goods.soup item = Item(search_goods.url[:-2]) item.analyze_soup(soup) logger.debug(item.url) item.fetch_info(fetchNumber) eel.message('情報取得完了') eel.viewInfo(item.item_info) eel.save_enable() except Exception as error: error_logger('情報取得エラー', error)
def fetch(): global driver global search global items try: search.fetch_item_url(driver) urls = search.itemUrls items = [] for i in range(5): item = Item(urls[i]) item.fetch_all(driver) items.append(item.item_info) eel.view_item_info(items) eel.message('抽出完了') except Exception as error: error_logger('抽出エラー', error) return None
def search(searchInfo): global driver try: if driver is None: driver = set_driver(IsHeadless) eel.message('検索中・・・', False, True) except Exception as error: error_logger('Seleniumドライバ設定エラー', error) return None try: logger.debug(searchInfo) search_goods.set_basic_info(searchInfo) search_url = search_goods.search_url logger.debug(search_url) driver.get(search_url) eel.message('検索完了') eel.fetch_enable() except Exception as error: error_logger('検索エラー', error)
def search(keyword): global driver global search try: if driver is None: driver = set_driver(IsHeadless) except Exception as error: error_logger('Seleniumドライバ設定エラー', error) return None try: url = 'https://ja.aliexpress.com/all-wholesale-products.html?spm=a2g0o.category_nav.0.0.300734f6uRXi28' search = Search(url, keyword) search.set_keyword(driver) search.set_currency(driver) search.get_category(driver) eel.message('検索完了、カテゴリを設定しました。絞り込みを必要に応じて設定してください。') eel.set_category_info(search.categories) eel.view_current_url(driver.current_url) except Exception as error: error_logger('検索エラー', error) return None
def error_logger(message, error): logger.error(message) logger.error(error) eel.message(message, True, False)