Please help me, I try to use the second time with xpath in lxml. But It's not work.
Here's my code:
from lxml import html,etree
import pprint
import requests
url="http://thuvienphapluat.vn"
page = requests.get(url)
tree=html.fromstring(page.content)
vbplm=tree.xpath('//div[@id="VBPLMOI"]//div[@class="left-col"]')
for vb in vbplm:
print etree.tostring(vb)
print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
print etree.tostring(vb.xpath('//a')[0],encoding='utf-8')
break
This line vb.xpath('//a')[0] extract image tag, it's not right with the a tag in vb:
<div class="left-col">
<div class="number">
1</div>
<div class="nq">
<p class="nqTitle" lawid="342726">
<a onclick="Doc_CT(MemberGA)" href="http://thuvienphapluat.vn/van-ban/Giao-duc/Van-ban-hop-nhat-02-VBHN-BGDDT-huong-dan-152-2007-QD-TTg-hoc-bong-chinh-sach-hoc-sinh-sinh-vien-342726.aspx">Văn bản hợp nhất 02/VBHN-BGDĐT năm 2017 hướng dẫn Quyết định 152/2007/QĐ-TTg về học bổng chính sách đối với học sinh, sinh viên học tại cơ sở giáo dục thuộc hệ thống giáo dục quốc dân do Bộ Giáo dục và Đào tạo ban hành</a>
</p>
<p class="links-bot">
<a onmouseover="LS_Tip_New(13,0,1)" onmouseout="hideddrivetip();" style="color:#AFAFAF;">Tiếng Anh</a>
|
<a onmouseover="LS_Tip_New(13,0,2)" onmouseout="hideddrivetip();" style="color:#AFAFAF;">Văn bản gốc</a>
|
<a onclick="Doc_Rel(MemberGA)" onmouseover="LS_Tip_New(13,0,4)" onmouseout="hideddrivetip();" href="http://thuvienphapluat.vn/van-ban/Giao-duc/Van-ban-hop-nhat-02-VBHN-BGDDT-huong-dan-152-2007-QD-TTg-hoc-bong-chinh-sach-hoc-sinh-sinh-vien-342726.aspx?tab=3">Lược đồ</a>
|
<a onclick="Doc_ST(MemberGA)" onmouseover="LS_Tip_New(13,0,3)" onmouseout="hideddrivetip();" href="http://thuvienphapluat.vn/van-ban/Giao-duc/Van-ban-hop-nhat-02-VBHN-BGDDT-huong-dan-152-2007-QD-TTg-hoc-bong-chinh-sach-hoc-sinh-sinh-vien-342726.aspx?tab=4">Liên quan hiệu lực</a>
|
<a onclick="Doc_DL(MemberGA)" href="http://thuvienphapluat.vn/van-ban/Giao-duc/Van-ban-hop-nhat-02-VBHN-BGDDT-huong-dan-152-2007-QD-TTg-hoc-bong-chinh-sach-hoc-sinh-sinh-vien-342726.aspx?tab=7">Tải về</a>
</p>
</div>
</div>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<a href="/" title="THƯ VIỆN PHÁP LUẬT">
<img src="/images/logo_xuan.png" alt="Logo" class="logo"/></a>
[Finished in 0.7s]