Hi Paul

And thank you for your reply

I have played around with the code a little (refer below) and revised the 
code to the follow. Attached or below is the screen shot from the Anaconda 
prompt below. It does not result in any syntax errors however I thought the 
code is meant to return results on the screen and nothing happen.

import scrapy

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)




<https://lh3.googleusercontent.com/-GiAVPeH6P08/V-4wNklifMI/AAAAAAAAWlY/560H4QV8wB0T4JDie9hcj4M4R_cpqBp6gCLcB/s1600/2016-09-30_1927.png>


On Wednesday, September 28, 2016 at 11:24:01 PM UTC+10, Paul Tremberth 
wrote:
>
> Hi Tim,
>
> what is the syntax error you are getting?
> can you copy-paste the text from your console? (not only the last line but 
> also lines before, the whole stacktrace)
>
> On Wednesday, September 28, 2016 at 3:16:53 PM UTC+2, Tim Fitzhardinge 
> wrote:
>>
>>
>> favorite 
>> <http://stackoverflow.com/questions/39687170/running-scrapy-tutorial-in-conda#>
>>
>> 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
>>
>> https://scrapy.org
>>
>> $ pip install scrapy
>> $ cat > myspider.py <<EOFimport scrapy
>> 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)
>> $ EOF
>>
>> scrapy runspider myspider.py
>>
>> I also tried replacing the first line with:
>>
>> conda install -c scrapinghub scrapy=1.1.2
>>
>> 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
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"scrapy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/scrapy-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to