0

I'm trying to run a scrapy spider from a simple PyQt4 GUI I built, the user has to fill his email and password to run the spider, the spider works well if I call it from the command prompt like so

scrapy crawl my_spider -a email -a password

So once the user has filled his email and password and I saved them in my script, and after reading the documentation and some examples I found of google I still can't figure out how to run it

    self.BumpPushButton.clicked.connect(self.BumpListings)

    def BumpListings(self):
        email = self.emailTextEdit.toPlainText()
        password = self.passwordTextEdit.toPlainText()
        bumpCycleInMinutes = self.MinutesTextEdit.toPlainText()

is there a simple way to call the spider at this point?

1 Answer 1

1

There are two approaches to this problem. You could call the spider directly by importing the spider or you could use python subprocesses. I would recommend python subprocesses because you don't want to block your pyqt process.

 import subprocess
 process = subprocess.Popen(['scrapy', 'crawl', 'my_spider', 
                                       '-a', email, '-a', password]
                             shell=True, 
                             stdout=subprocess.PIPE, 
                             stderr=subprocess.PIPE) 

You can then check on the process using wait, communicate, poll etc. See docs to see what actions you might want to perform.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.