Compare commits
No commits in common. "3c30b42f75ecb0b3cae3e66df04f309bcc9d2045" and "a7952bc32c45a1427631b26cade9bbe39cf2c9b2" have entirely different histories.
3c30b42f75
...
a7952bc32c
19
scrarls.py
19
scrarls.py
@ -4,7 +4,6 @@ import re
|
||||
import sys
|
||||
|
||||
from datetime import datetime
|
||||
from multiprocessing import Process
|
||||
|
||||
import scrapy
|
||||
from scrapy.crawler import CrawlerProcess
|
||||
@ -174,25 +173,11 @@ class TvShow(CrawlSpider):
|
||||
return datetime.strptime(formatted_date, "Posted on %B %d, %Y at %H:%M in")
|
||||
|
||||
|
||||
def run_scrapy():
|
||||
def main():
|
||||
process = CrawlerProcess()
|
||||
_ = process.crawl(TvShow)
|
||||
process.start()
|
||||
|
||||
|
||||
def main():
|
||||
p_scrapy = Process(target=run_scrapy)
|
||||
|
||||
try:
|
||||
p_scrapy.start()
|
||||
except KeyboardInterrupt:
|
||||
print(f"Closing...")
|
||||
p_scrapy.terminate()
|
||||
p_scrapy.join(timeout=30)
|
||||
if p_scrapy.is_alive():
|
||||
print("⚠️ Scrapy n'a pas pu s'arrêter proprement.")
|
||||
p_scrapy.kill()
|
||||
print(f"scrarls is stopped.")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user