Hi I'm new to Python and running python scripts. I am using Anaconda I wanted to run the scrapy tutorial on the home page of the website scrapy runspider myspider.py I also tried replacing the first line with: I saved a myspider.py on my user c drive folder. I copied the whole code however when I tried to run the script using python myspider.py in the anaconda prompt it does not work and returns with a syntax error. What is the syntax of the tutorial that I should use for running in anaconda. Thanks |
class BlogSpider(scrapy.Spider): name = 'blogspider' start_urls = ['https://blog.scrapinghub.com']
def parse(self, response): for title in response.css('h2.entry-title'): yield {'title': title.css('a ::text').extract_first()}
next_page = response.css('div.prev-post > a ::attr(href)').extract_first() if next_page: yield scrapy.Request(response.urljoin(next_page), callback=self.parse)