Issue
I want to select the text inside these tags, how can I select them ( i want to select the name and comment in a post on the Facebook fan page)?
- I have 2 div tags like this
<div class="_2b05">
<a href="/profile.php?id=100003980635623&fref=nf&rc=p&__tn__=R">
<div class="_7_cb _3-8m">
<i class="_3-8_ img sp_VfPHLawdqPX sx_0636a9"></i>
Fan cứng
</div>
Hải Ka
</a>
</div><div data-commentid="511961943618859" data-sigil="comment-body">
Ráng lướt rồi cũng sẽ qua<span class="_5mfr"><span class="_6qdm" style="height: 16px; width: 16px; font-size: 16px; background-image: url("https://static.xx.fbcdn.net/images/emoji.php/v9/t81/1/16/1f60c.png")">😌</span></span></div>
<div class="_2b05">
<a href="/leminhnhut2110?fref=nf&rc=p&__tn__=R">
Lê Minh Nhựt</a>
</div>
<div data-commentid="511968943618159" data-sigil="comment-body">Làm ngụm Oolong cho phẻ m.n êijii</div>
i succeced to select comments by use xpath like this
response.xpath('//div[contains(@data-sigil,"comment-body")]/text()')
but with the name there are some problem with Fan tag. i used this xpath:
response.xpath('//div[contains(@data-sigil,"comment-body")]//preceding-sibling::div/a/text()')
it only show the comment's user name if not have Fan text. How can i skip Fan text and only choose text contain the name of user? Thanks
Some pic about it: with Fan text: without Fan text:
update: sorry, my problem is not fan text. You can read my conversation between me and sir F.Hoque to know more. Thanks
Solution
response.xpath('//div[contains(@data-sigil,"comment-body")]/text()')
Output:
(The above xpath selection will return the following output)
Ráng lướt rồi cũng sẽ qua
Làm ngụm Oolong cho phẻ m.n êijii
Select user name:
response.xpath('//div[@class="_2b05"]/a/text()')
Output:
Hải Ka
Lê Minh Nhựt
Answered By - F.Hoque
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.