def INFO_BOX_TPE_INIT(): row_data = read_excel("sells/data/TPE/info/total_rows_TPE.xlsx") # get the excel info info_boxes = [] for data in row_data: page = get_web_page(DETAIL_URL + data["url"], urlJumpIp) info_boxes += get_info_box(page, data["post_id"]) showProgess(__file__) save(info_boxes, "sells/data/TPE/info/info_box_TPE") print(str(__file__) + " complete")
def HOUSE_BOX_TPE_INIT(): row_data = read_excel("lease/data/TPE/info/total_rows_TPE.xlsx") # get the excel info house_boxes = [] for data in row_data: page = get_web_page(DETAIL_URL + data["url"], urlJumpIp) house_boxes += get_house_box(page, data["post_id"]) showProgess(__file__) save(house_boxes, "lease/data/TPE/info/house_box_TPE") print(str(__file__) + " complete")
def MYSQL_DUMP_VERTEX(): # ====== Connection ====== # # Connecting to mysql by providing a sqlachemy engine engine = MY_ENGINE() # dump dist excel to mysql floorNumber = 9 for i in range(0, floorNumber): fileName = "C:\\Users\\A02wxy\\Documents\\GitHub\\WayFinder\\Direction\\Route\\vertex\\sf" + str( i + 1) + "f_vertex.xlsx" tableName = "sf" + str(i + 1) + "f_vertex" df = read_excel(fileName) df.to_sql(name=tableName, if_exists="replace", con=engine, index=False)
def IMG_TPE_INIT(): row_data = read_excel( "sells/data/TPE/info/total_rows_TPE.xlsx") # get the excel info dir = "D:/Python/database/sells/images/TPE/" if os.path.exists(dir): # 先刪除原本的images資料夾 shutil.rmtree(dir, ignore_errors=True) for data in row_data: page = get_web_page(DETAIL_URL + data["url"], urlJumpIp) img_urls = get_images(page) save(img_urls, data["post_id"], dir) showProgess(__file__) print(str(__file__) + " complete")
import googlemaps import sys sys.path.append("lib/") from datetime import datetime from myio import read_excel, save def get_geoLoc(row_data): geo_result = [] for data in row_data: coordinate = gmaps.geocode(data["addr"])[0]["geometry"]["location"] print(data["addr"] + ":", coordinate) geo_result.append({"addr": data["addr"], "coordinate": coordinate}) return geo_result if __name__ == "__main__": gmaps = googlemaps.Client(key="AIzaSyDcixkMKgROY2tE_4VLPTioPtDOwbmzfcI") # data for lease NTC row_data = read_excel("lease/data/NTC/info/total_rows_NTC.xlsx") geo_result = get_geoLoc(row_data) save(geo_result, "lease/data/TPE/geo/coordinate/loc_NTC") # data for sells NTC row_data = read_excel("sells/data/NTC/info/total_rows_NTC.xlsx") geo_result = get_geoLoc(row_data) save(geo_result, "sells/data/TPE/geo/coordinate/loc_NTC")
import googlemaps import sys sys.path.append("lib/") from datetime import datetime from myio import read_excel, save def get_geoLoc(row_data): geo_result = [] for data in row_data: coordinate = gmaps.geocode(data["addr"])[0]["geometry"]["location"] print(data["addr"] + ":", coordinate) geo_result.append({"addr": data["addr"], "coordinate": coordinate}) return geo_result if __name__ == "__main__": gmaps = googlemaps.Client(key="AIzaSyDcixkMKgROY2tE_4VLPTioPtDOwbmzfcI") # data for lease TPE row_data = read_excel("lease/data/TPE/info/total_rows_TPE.xlsx") geo_result = get_geoLoc(row_data) save(geo_result, "lease/data/TPE/geo/coordinate/loc_TPE") # data for sells TPE row_data = read_excel("sells/data/TPE/info/total_rows_TPE.xlsx") geo_result = get_geoLoc(row_data) save(geo_result, "sells/data/TPE/geo/coordinate/loc_TPE")