Skip to content

How to Stop the crawler without pressing CTRL + C? #291

Answered by spiderseo
spiderseo asked this question in Q&A
Discussion options

You must be logged in to vote

Hey Elias! This is the solution to track the specific Spider on Windows, I built script:

import platform, psutil
import pandas as pd

class SpiderTracker:

def __init__(self) ->:

    self.operating_system:str = platform.system()
    self.process_name:str = {"Linux":"scrapy", "Windows":'scrapy.exe'}[self.operating_system]
    self.process_args_to_kil:list[str] = {"Linux":['kill', '-9'], "Windows":['taskkill', '/F', '/PID']}[self.operating_system]

def get_running_spiders(self) -> list[dict]:

    """Returns as list of dictionaries containing running scrapy spiders, where the cmdline key has the spider data and the pid has the process id of that specific spider."""
    running_spiders:list =…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@spiderseo
Comment options

@eliasdabbas
Comment options

Comment options

You must be logged in to vote
1 reply
@spiderseo
Comment options

Comment options

You must be logged in to vote
1 reply
@eliasdabbas
Comment options

Answer selected by spiderseo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants