l_tmpB = os.path.join(g_118218Dir, '__tmpB_{0}.csv'.format(l_communeId)) if not os.path.isfile(l_tmpA) and not os.path.isfile(l_tmpA): print('Search for "{0}" in "{1}" ...'.format(l_search, l_communeName)) l_count = doSearch(l_search, l_communeName, l_tmpA, l_tmpB, l_minDelay, l_maxDelay, l_distance) l_totalCount += l_count print('Search for "{0}" in "{1}" Complete'.format(l_search, l_communeName)) if l_count == 0: CommonFunctions.randomWait(l_minDelay, l_maxDelay) print('Total number of items retrieved:', l_totalCount) # merge the tmp files CommonFunctions.concatTmp(g_118218Dir, [i for i, c in l_communes], l_pathA, l_pathB) # sort the result CommonFunctions.csvSort(l_pathA, p_départements=True) else: # otherwise, do an ordinary search doSearch(l_search, l_location, l_pathA, l_pathB, l_minDelay, l_maxDelay, l_distance) # and sort the results as well CommonFunctions.csvSort(l_pathA) # displays parameters again print('------------------------------------------------------') print('Search keyword(s) :', c.search) print('Location :', c.location) if l_minDelay > 0: print('Minimum delay (s.) :', c.min)
print('Search for "{0}" in "{1}" ...'.format(l_search, l_communeName)) l_count = doSearch(l_search, l_communeName, l_tmpA, l_tmpB, l_minDelay, l_maxDelay) l_totalCount += l_count print('Search for "{0}" in "{1}" Complete'.format(l_search, l_communeName)) if l_count == 0: CommonFunctions.randomWait(l_minDelay, l_maxDelay) # if l_totalCount > 300: # break print('Total number of items retrieved:', l_totalCount) # merge the tmp files CommonFunctions.concatTmp(g_misterWhatDir, [i for i, c in l_communes], l_pathA, l_pathB) # sort the result CommonFunctions.csvSort(l_pathA, p_départements=True) else: # otherwise, do an ordinary search doSearch(l_search, l_location, l_pathA, l_pathB, l_minDelay, l_maxDelay) # and sort the results as well CommonFunctions.csvSort(l_pathA) # displays parameters again print('------------------------------------------------------') print('Search keyword(s) :', c.search) print('Location :', c.location) if l_minDelay > 0: print('Minimum delay (s.) :', c.min)
print('Maximum delay (s.) :', c.max) # do the per-département search if the location parameter is 'France' if l_location.lower() == 'france': print('Location = France --> search all départements') # one tmp file per département for l_dépNum in l_départements: l_tmpA = os.path.join(g_PagesJaunesDir, '__tmpA_{0}.csv'.format(l_dépNum)) l_tmpB = os.path.join(g_PagesJaunesDir, '__tmpB_{0}.csv'.format(l_dépNum)) if not os.path.isfile(l_tmpA) and not os.path.isfile(l_tmpA): doSearch(l_search, l_dépNum, l_tmpA, l_tmpB, l_minDelay, l_maxDelay) # merge the tmp files CommonFunctions.concatTmp(g_PagesJaunesDir, l_départements, l_pathA, l_pathB) # sort the result CommonFunctions.csvSort(l_pathA, p_départements=True) else: # otherwise, do an ordinary search doSearch(l_search, l_location, l_pathA, l_pathB, l_minDelay, l_maxDelay) # and sort the results as well CommonFunctions.csvSort(l_pathA) # displays parameters again print('------------------------------------------------------') print('Search keyword(s) :', c.search) print('Location :', c.location) if l_minDelay > 0: print('Minimum delay (s.) :', c.min)