added all defs to main def

This commit is contained in:
spbeach46 2020-06-11 18:26:32 -07:00
parent f40825139b
commit 869a4613fb

18
posh.py
View File

@ -7,7 +7,9 @@ import numpy as np
# import matplotlib.pyplot as plt
def url_base_builder(search_query):
def main():
def url_base_builder(search_query):
genders = ['Men', 'Women']
posh_colors = ['Red', 'Pink', 'Orange', 'Yellow', 'Green', 'Blue', 'Purple',
@ -41,7 +43,7 @@ def url_base_builder(search_query):
return all_sold_url_base, new_sold_url_base
def all_sold_list_builder(i):
def all_sold_list_builder(i):
bases = url_base_builder(search_query)
all_sold_url_base = bases[0]
all_sold_prices = []
@ -59,7 +61,7 @@ def all_sold_list_builder(i):
return all_sold_prices
def new_sold_list_builder(i):
def new_sold_list_builder(i):
bases = url_base_builder(search_query)
new_sold_url_base = bases[1]
new_sold_prices = []
@ -77,14 +79,11 @@ def new_sold_list_builder(i):
new_sold_prices.append(price)
return new_sold_prices
def main():
search_query = str(input('Title Search: '))
start = time.time()
page_list = list(range(1, 2))
page_list = list(range(1, 5))
all_sold_list = []
new_sold_list = []
@ -116,5 +115,8 @@ def main():
print('Average New Sold Price', average_new_sold_price, new_sold_results)
print(total_results)
main()
if __name__ == '__main__':
main()
'''to speed up the program you can include a few things: 1) only parse the total results and sift for the NWT listings to create a separate NWT list 2) Implement processpoolexecutor to use more than one worker to parse the pages 3) find a better way to find the last page so you don't have to make more requests than necessary. This could be either taking the "smallest" "no listings found" page of the pages while excluding the others after the smallest one is found. Or, determining from the request headers whether a page is worth downloading or not 4) using a while loop in chunks of 2-4 pages to find the last page in conjunction with number 3'''