0
일부 정보를 얻기 위해 일부 웹 페이지를 고칩니다. 나는 Scrapy와 XPath 언어를 사용하고있다.XPath를 사용하여 웹 페이지 스크랩
이것은 내가 얻을 수있는 페이지의 예입니다. 이 페이지에서이 많은 요소가 있습니다.
<li ckIgnore="false" codmod="3857" ccar="A" area="NEW" versArea="NEW" shorturl="1" modurl="/auto">
<article>
<a href=""><img width="210" height="158" src="" alt="" modello=></a>
<img src="" alt="logo" class="logo-listing" width="38">
<div class="hgroup">
<a href="">
<h5>ABARTH</h5>
<h3>500 cabrio</h3>
</a>
</div>
</article>
</li>
이 구문을 사용하여 hgroup 클래스가있는 모든 div를 가져옵니다. 불행히도 모델 변수를 출력하려고 할 때이 변수는 비어 있습니다.
def parse(self, response):
sel = Selector(response)
models = sel.xpath("//div[@class='hgroup']/a")
뜻 :'models == []'? – kev
예 정확하게 python 인쇄 모델로 모델을 인쇄하면 [] –
응답을 원시 HTML :'print response.body'로 인쇄하십시오. – kev