我刚刚开始使用刮刮网站刮。我读过一些指向html页面的文档。我在eentertainment网站上试过,我只是想把图片的标题去掉。后来的价格和形象。写作时我什么也得不到。谁能指出我哪里做错了吗。你知道吗
这是密码。你知道吗
# -*- coding: utf-8 -*-
import scrapy
class EeentertainmentSpider(scrapy.Spider):
name = 'eeentertainment'
allowed_domains = ['www.entertainmentearth.com/exclusives.asp']
start_urls = ['http://www.entertainmentearth.com/exclusives.asp/']
def parse(self, response):
#Extracting the content using css selectors
titles = response.css('.title::text').extract()
#Give the extracted content row wise
for item in zip(titles):
#create a dictionary to store the scraped info
scraped_info = {
'title' : item[0],
}
#yield or give the scraped info to scrapy
yield scraped_info
pass
你的蜘蛛有几个问题:
allowed_domains
列表应该只包含域名,而不是确切的url(参见documentation)start_urls
中的URL后面有一个/
(应该是http://www.entertainmentearth.com/exclusives.asp
)zip
做什么,但我几乎可以肯定这不是有意的parse
方法末尾的{根据我提供的屏幕截图可以看出,您正试图从页面中刮取图像标题。为此,考虑到上述注意事项,请参阅适用的spider代码:
相关问题 更多 >
编程相关推荐