【发布时间】:2017-09-09 02:37:34
【问题描述】:
我基本上想在<h3 class="Sans-17px-black-85%-semibold"> 下刮Litigation Paralegal 和在<span class="pv-entity__secondary-title Sans-15px-black-55%"> 下刮Olswang,但我看不到它。这是代码中的 HTML:
<div class="pv-entity__summary-info">
<h3 class="Sans-17px-black-85%-semibold">Litigation Paralegal</h3>
<h4>
<span class="visually-hidden">Company Name</span>
<span class="pv-entity__secondary-title Sans-15px-black-55%">Olswang</span>
</h4>
<div class="pv-entity__position-info detail-facet m0"><h4 class="pv-entity__date-range Sans-15px-black-55%">
<span class="visually-hidden">Dates Employed</span>
<span>Feb 2016 – Present</span>
</h4><h4 class="pv-entity__duration de Sans-15px-black-55% ml0">
<span class="visually-hidden">Employment Duration</span>
<span class="pv-entity__bullet-item">1 yr 2 mos</span>
</h4><h4 class="pv-entity__location detail-facet Sans-15px-black-55% inline-block">
<span class="visually-hidden">Location</span>
<span class="pv-entity__bullet-item">London, United Kingdom</span>
</h4></div>
</div>
这是我目前在代码中使用 selenium 所做的事情:
if tree.xpath('//*[@class="pv-entity__summary-info"]'):
experience_title = tree.xpath('//*[@class="Sans-17px-black-85%-semibold"]/h3/text()')
print(experience_title)
experience_company = tree.xpath('//*[@class="pv-position-entity__secondary-title pv-entity__secondary-title Sans-15px-black-55%"]text()')
print(experience_company)
我的输出:
体验标题:[]
[]
【问题讨论】:
标签: python-2.7 selenium xpath