Re: [問題] pyquery

看板Python作者 (poototo)時間3年前 (2021/05/04 16:01), 編輯推噓1(100)
留言1則, 1人參與, 3年前最新討論串2/2 (看更多)
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://www.ptt.cc/bbs/Python/M.1620115263.A.F15.html

05/04 21:35, 3年前 , 1F
原來是這樣!太感謝了
05/04 21:35, 1F
文章代碼(AID): #1WaFy_yL (Python)
討論串 (同標題文章)
本文引述了以下文章的的內容:
3
7
完整討論串 (本文為第 2 之 2 篇):
3
7
1
1
文章代碼(AID): #1WaFy_yL (Python)