0.0.9
This commit is contained in:
@@ -59,28 +59,34 @@ class Api:
|
||||
return None
|
||||
return response
|
||||
|
||||
# def main():
|
||||
# """
|
||||
# 从同目录的 `bakeries.csv` 读取面包店数据,按列映射输出或创建店铺
|
||||
def main():
|
||||
"""
|
||||
从同目录的 `bakeries.csv` 读取面包店数据,按列映射输出或创建店铺
|
||||
|
||||
# 列顺序:`Name,Address,City`
|
||||
# """
|
||||
# api = Api()
|
||||
# csv_path = os.path.join(os.path.dirname(__file__), 'bakeries.csv')
|
||||
# if not os.path.exists(csv_path):
|
||||
# logger.error(f'CSV 文件不存在: {csv_path}')
|
||||
# return
|
||||
列顺序:`Name,Address,City`
|
||||
"""
|
||||
api = Api()
|
||||
csv_path = os.path.join(os.path.dirname(__file__), 'bakeries.csv')
|
||||
if not os.path.exists(csv_path):
|
||||
logger.error(f'CSV 文件不存在: {csv_path}')
|
||||
return
|
||||
|
||||
# with open(csv_path, 'r', encoding='utf-8') as file:
|
||||
# reader = csv.reader(file)
|
||||
# header = next(reader, None)
|
||||
# for row in reader:
|
||||
# if len(row) < 3:
|
||||
# logger.warning(f'行列数不足,跳过: {row}')
|
||||
# continue
|
||||
# shop_name, street, city = row[0], row[1], row[2]
|
||||
# logger.info(f'city: {city}, street: {street}, shop_name: {shop_name}')
|
||||
# api.create_shop(city, street, shop_name)
|
||||
with open(csv_path, 'r', encoding='utf-8') as file:
|
||||
reader = csv.reader(file)
|
||||
header = next(reader, None)
|
||||
for row in reader:
|
||||
if len(row) < 3:
|
||||
logger.warning(f'行列数不足,跳过: {row}')
|
||||
continue
|
||||
shop_name, street, city = row[0], row[1], row[2]
|
||||
if ' (city)' in city:
|
||||
city = city.replace(' (city)', '')
|
||||
if 'Quebec' in city:
|
||||
continue
|
||||
if ',' in city:
|
||||
city = city.split(',')[0]
|
||||
logger.info(f'city: {city}, street: {street}, shop_name: {shop_name}')
|
||||
api.create_shop(city, street, shop_name)
|
||||
|
||||
# def main2():
|
||||
# api = Api()
|
||||
|
||||
@@ -380,15 +380,15 @@ class Auto:
|
||||
# 取对应城市的代理
|
||||
def get_proxy( city: str):
|
||||
if city == "Calgary":
|
||||
return "us.novproxy.io:1000:uwqr8065-region-CA-st-Alberta-city-Calgary:d6vqwerx".split(':')
|
||||
return "us.novproxy.io:1000:ozua8623-region-CA-st-Alberta-city-Calgary:6wdcv4gq".split(':')
|
||||
elif city =='Edmonton':
|
||||
return 'us.novproxy.io:1000:uwqr8065-region-CA-st-Alberta-city-Edmonton:d6vqwerx'.split(':')
|
||||
return 'us.novproxy.io:1000:ozua8623-region-CA-st-Alberta-city-Edmonton:6wdcv4gq'.split(':')
|
||||
elif city =='Vancouver':
|
||||
return 'us.novproxy.io:1000:uwqr8065-region-CA-st-British Columbia-city-Vancouver:d6vqwerx'.split(':')
|
||||
return 'us.novproxy.io:1000:ozua8623-region-CA-st-British Columbia-city-Vancouver:6wdcv4gq'.split(':')
|
||||
elif city =='Halifax':
|
||||
return 'us.novproxy.io:1000:uwqr8065-region-CA-st-Nova Scotia-city-Halifax:d6vqwerx'.split(':')
|
||||
return 'us.novproxy.io:1000:ozua8623-region-CA-st-Nova Scotia-city-Halifax:6wdcv4gq'.split(':')
|
||||
elif city == 'Toronto':
|
||||
return 'us.novproxy.io:1000:uwqr8065-region-CA-st-Ontario-city-Toronto:d6vqwerx'.split(':')
|
||||
return 'us.novproxy.io:1000:ozua8623-region-CA-st-Ontario-city-Toronto:6wdcv4gq'.split(':')
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user