我已经写了一些蜘蛛,似乎为其他网站工作。这个一直给我带来麻烦。 这是我的蜘蛛代码。你知道吗
from sears.items import SwatchcolorItem
class SattySpider(scrapy.Spider):
name = "searsfaucet"
allowed_domains = ["sears.com"]
start_urls = [
"http://www.sears.com/search=faucets?catalogId=12605&storeId=10153&levels=Home%20Improvement"
]
rules = (
Rule(LinkExtractor(allow='sears\.com/[A-Z][a-zA-Z_/]+$'),
'parse_category', follow=True,
),
)
def parse(self, response):
print 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
#for sel in response.xpath('//li[@class="product-wrapper grid-25 tablet-grid-33 v-spacing-large"]'):
#for sel in response.xpath('//div[@ng-app="searchApp"]//div[@id="content"]//div[@ng-switch="resultTemplate"]'):
for sel in response.xpath('//div[@ng-app="searchApp"]//div[@id="content"]'):
print sel
prod= sel.xpath('.//div[@ng-switch="resultTemplate"]')
print prod
produrls = sel.xpath('.//@data-producturl').extract()
urls = sel.xpath('.//@data-productimg').extract()
#prod_url_det = response.urljoin(produrl.extract())
即使是我的脏壳似乎也没有回报。你知道吗
此xpath似乎正在返回结果:
response.xpath('//div[@ng-app="searchApp"]//div[@id="content"]')
但是,以下情况并非如此:
response.xpath('//div[@ng-app="searchApp"]//div[@id="content"]//div[@ng-switch="resultTemplate"]')
response.xpath('//div[@ng-app="searchApp"]//div[@id="content"]//div[@class="ng-scope"]')
看起来很直截了当。不知道我错过了什么。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐