scrapy / scrapyd

A service daemon to run Scrapy spiders
https://scrapyd.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
2.92k stars 569 forks source link

May I ask is there any way use scrpyd to run python script with CrawlerProcess #489

Closed xinatcg closed 1 year ago

xinatcg commented 1 year ago

May I ask if is there any way use scrpyd to run Python script with CrawlerProcess

for example, the use case is: we have some custom logic for python script before run spider.

jpmckinney commented 1 year ago

Scrapyd essentially calls scrapy crawl on your project.

https://github.com/scrapy/scrapyd/blob/90b10234add797131996436cbba2ac4f3371de39/scrapyd/runner.py#L41-L45

https://github.com/scrapy/scrapyd/blob/90b10234add797131996436cbba2ac4f3371de39/scrapyd/launcher.py#L36-L49

Generally, you should be able to achieve anything you need by using the spider_opened signal.

If you're doing something very unusual, you'll have to share some example code for me to understand.

xinatcg commented 1 year ago

Scrapyd essentially calls scrapy crawl on your project.

https://github.com/scrapy/scrapyd/blob/90b10234add797131996436cbba2ac4f3371de39/scrapyd/runner.py#L41-L45

https://github.com/scrapy/scrapyd/blob/90b10234add797131996436cbba2ac4f3371de39/scrapyd/launcher.py#L36-L49

Generally, you should be able to achieve anything you need by using the spider_opened signal.

If you're doing something very unusual, you'll have to share some example code for me to understand.

Thanks very much, we will have a look!