[問題] BeautifulSoup4使用問題

看板Python作者 (累人啊....)時間7年前 (2018/03/04 16:20), 編輯推噓0(003)
留言3則, 3人參與, 7年前最新討論串1/1
如題,照著書上的教學作測試,得到預期外的結果 (使用Python3.4, OS windows 8.1) 書本爬這個網頁作範例 https://goo.gl/Htv4bm 也提供了程式碼供下載 https://goo.gl/Qjz2eN 預期只會得到清單的各個名稱 Vegetable Basket Russian Nesting Dolls ...(略) span等等的那些也都抓到了,同樣測試了descendants及next_siblings,也得到奇怪的結果 請問是我對預期的結果有誤會嗎?以下附上一部份測試得到的結果 再麻煩解答,謝謝 <tr><th> Item Title </th><th> Description </th><th> Cost </th><th> Image </th></tr> <tr class="gift" id="gift1"><td> Vegetable Basket </td><td> This vegetable basket is the perfect gift for your health conscious (or overweight) friends! <span class="excitingNote">Now with super-colorful bell peppers!</span> </td><td> $15.00 </td><td> <img src="../img/gifts/img1.jpg"/> </td></tr> <tr class="gift" id="gift2"><td> ... (略,id = gift1~gift5都有列出來,格式同上) -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.228.239.196 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1520151617.A.5CB.html

03/04 16:48, 7年前 , 1F
抱歉,看懂了,排序一下html的格式後就看出來了
03/04 16:48, 1F

03/06 03:35, 7年前 , 2F
03/06 03:35, 2F

03/06 04:14, 7年前 , 3F
03/06 04:14, 3F
文章代碼(AID): #1Qcwn1NB (Python)
文章代碼(AID): #1Qcwn1NB (Python)