作者poototo (poototo)
标题Re: [问题] pyquery
时间Tue May 4 16:01:00 2021
from pyquery import PyQuery as pq
#
html = '''
<html>
<a data-v-54b96320="" href="/magic/11320" target="_blank"
class="m-card-s">
<a data-v-54b96320="" href="/magic/11320aaa" target="_blank"
class="m-card-s">
<a data-v-54b96320="" href="/magic/11320bbb" target="_blank"
class="m-card-s">
</html>
'''
doc = pq(html)
all_a = doc.find('a')
for a in all_a:
a = pq(a)
href = a.attr('href')
print(href)
※ 引述《bchoice (choice)》之铭言:
: 我用pyquery後
: 该怎麽撷取 href="/magic/11320 这段文字
: <a data-v-54b96320="" href="/magic/11320" target="_blank" class="m-card-s">
: 感谢各位前辈
: doc = pq(html)
: a = doc('a')
: for item in a.items():
: href = item.attr('href')
: print (href)
: 我的程式是这样,该怎麽改
: 感谢
--
You love playing with that.
You love playing with all your stuffed animals.
You love your mommy,your daddy,your nature pajamas.
You love everything,don't you?
Yeah,
You know what,buddy?
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 220.138.25.226 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1620115263.A.F15.html
1F:推 bchoice: 原来是这样!太感谢了 05/04 21:35