2023-05-01 11:57:33 +02:00
|
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
|
|
|
2023-05-01 11:16:10 +02:00
|
|
|
from csv_exporter import export_attraction
|
|
|
|
from tripadvisor_parser import TripadvisorAttractionParser
|
|
|
|
|
|
|
|
|
2023-05-01 11:57:33 +02:00
|
|
|
def parse_and_export_attraction(url: str):
|
2023-05-01 11:16:10 +02:00
|
|
|
parser = TripadvisorAttractionParser(url.strip())
|
2023-05-01 11:57:33 +02:00
|
|
|
attraction = parser.parse()
|
|
|
|
export_attraction(attraction)
|
2023-05-01 11:16:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
def get_urls() -> [str]:
|
|
|
|
with open("urls.txt", "r") as urls_file:
|
|
|
|
return urls_file.readlines()
|
|
|
|
|
|
|
|
|
2023-05-01 11:19:36 +02:00
|
|
|
def main():
|
2023-05-01 11:57:33 +02:00
|
|
|
with ThreadPoolExecutor() as executor:
|
|
|
|
executor.map(parse_and_export_attraction, get_urls())
|
2023-05-01 11:19:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|