Dominic Pham
10/13/2021, 1:00 AMKeyError: 'Spider not found: 'scraper'
when I try to run debug my program. However when I try to define the function the task is calling manually, it works as intended.nicholas
Dominic Pham
10/13/2021, 4:04 PM-Project
|--outputs
|--scraper
|--spiders
|--flow.py
|--scrapy_api_script.py
|--scrapy.cfg
Dominic Pham
10/13/2021, 4:15 PMfrom scraper_api import instantiate_web_scraper
@task
def scrapy_api_call(job_list:list):
# Call the scrapy API file for the scraper. Using job titles from the db output as inputs for the API call.
for title in job_list[0]:
return scraper_api.instantiate_web_scraper(title)
def prefect_flow():
with Flow("Pipeline") as flow:
db_pull = connection()
run_scraper = scrapy_api_call(db_pull)
flow.run()
if __name__=="__main__":
prefect_flow()
nicholas
flow.run()
outside of the flow context? i.e.:
def prefect_flow():
with Flow("Pipeline") as flow:
# ..
flow.run()
Dominic Pham
10/13/2021, 4:24 PMKeyError 'Spider not found: scraper'
File "C:\Users\x\x\Documents\Prefect Projects\Prefect-Projects\scraper\scraper_api.py", line 6, in instantiate_web_scraper
process.crawl("indeed_scraper", title=job_title)
File "C:\Users\x\x\Documents\Prefect Projects\Prefect-Projects\Cscraper\01_instantiate_scraper.py", line 52, in scrapy_api_call (Current frame)
return instantiate_web_scraper(title)
File "C:\Users\x\x\Documents\Prefect Projects\Prefect-Projects\scraper\01_instantiate_scraper.py", line 60, in prefect_flow
flow.run()
File "C:\Users\x\x\Documents\Prefect Projects\Prefect-Projects\scraper\01_instantiate_scraper.py", line 63, in <module>
prefect_flow()
nicholas
scraper_api
, you’re importing instantiate_web_scraper
but still calling scraper_api.instantiate_web_scraper
Dominic Pham
10/13/2021, 4:33 PM