Using Python Version 2.7.10 I downloaded Scrapy and on Version 1.4.0 I'm questioning where exactly I need to have these installed? I changed my filename from scrapy.py to scrapy123.py to no avail. I'm frustrated! ha
Receiving the infamous error of:
Traceback (most recent call last):
File "/Users/william/PycharmProjects/scrapy123.py", line 1, in <module>
import scrapy
ModuleNotFoundError: No module named 'scrapy'
Script:
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)
using the pep-0328 __future__
absolute_import
helps to make this less ambiguous and has been supported from 2.5.
from __future__ import absolute_import
Then you can simply import .scrappy
and make sure it is loading the version expected. It will also help when moving to Python3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.