작성
·
141
답변 1
0
안녕하세요. 다음과 같이 정상동작을 하는데요.
아마도 css selector 선택이 잘못되었을 확률이 높아보여요. type 으로도 get() 까지 나오는 값이 어느 타입인지도 확인해보시면 좋을 것 같습니다.
ecommerce/ecommerce scrapy shell 'http://corners.gmarket.co.kr/Bestsellers'
[s] Available Scrapy objects:
[s] scrapy scrapy module (contains scrapy.Request, scrapy.Selector, etc)
[s] crawler <scrapy.crawler.Crawler object at 0x7f818292d5d0>
[s] item {}
[s] request <GET http://corners.gmarket.co.kr/Bestsellers>
[s] response <200 http://corners.gmarket.co.kr/Bestsellers>
[s] settings <scrapy.settings.Settings object at 0x7f8182928e10>
[s] spider <DefaultSpider 'default' at 0x7f8183983190>
[s] Useful shortcuts:
[s] fetch(url[, redirect=True]) Fetch URL and update local objects (by default, redirects are followed)
[s] fetch(req) Fetch a scrapy.Request and update local objects
[s] shelp() Shell help (print this help)
[s] view(response) View response in a browser
In [1]: view(response)
Out[1]: True
In [2]: response.css('div.best-list li > a::text')[1].re('(\w+)')
Out[2]: ['프리메라', '프리메라', '리페어빈', '시카', '크림', '40ml', '기획세트']
In [2]: response.css('div.best-list li > a::text')[1].re('(\w+)')
Out[2]: ['프리메라', '프리메라', '리페어빈', '시카', '크림', '40ml', '기획세트']
In [3]: type(response.css('div.best-list li > a::text')[1])
Out[3]: scrapy.selector.unified.Selector
In [4]: type(response.css('div.best-list li > a::text'))
Out[4]: scrapy.selector.unified.SelectorList