Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrapy debug using Visual Studio

I am new to Scrapy and Python and I am enjoying it.

Is it possible to debug a scrapy project using Visual Studio? If it is possible, how?

like image 727
user3860415 Avatar asked Mar 18 '23 23:03

user3860415


2 Answers

I've created a init file named runner.py

from scrapy.cmdline import execute
execute(['scrapy','crawl', 'spider_name'])

you just need to set that file as the startup in the project options.

it works with visual studio 2015

like image 166
pedrommuller Avatar answered Apr 07 '23 09:04

pedrommuller


You can install PTVS in visual studio 2012. Then create a python project from existing python code, and import your code.

If you are familiar with Visual Studio, it's the same as other languages in Visual Studio, like C++/C#. Just create some break points and start your script with Debugging.

As ThanhNienDiCho said, add "-mscrapy.cmdline crawl your_spider_name" to your interpreter argument.

PTVS screenshot

like image 39
Yuan Avatar answered Apr 07 '23 10:04

Yuan