[問題] 網頁分析之print問題
晚安,很高興在這裡問問題,提升程式功力
2. 請看我程式碼
import requests
import re
from BeautifulSoup import BeautifulSoup
import HTMLParser
links = ['https://goo.gl/dBtn3H']
上述的程式碼大概說明是我爬蟲了一個叫做https://goo.gl/dBtn3H的網頁,我接下來為會擷取我想要的一段網頁內容,如下所示
#抓取使用者所收藏的標籤(未處理)
for link in links:
res = requests.get(link)
soup = BeautifulSoup(res.text.encode("utf-8"))
shop_table = soup.findAll('div',{'class':'userListTags'})
shop_table[0].findAll('a',{'href':True})
for each in shop_table:#印出所
print(each)
print each#出問題了 沒有印出全部資料
上述有兩次擷取,第一次為div.....,第二次為 shop_table[0].findAll('a',{'href':True})
我想請問當我用for迴圈( for each in shop_table:)時可以印出所有我想要的資料,但是我當我外在for迴圈外面再寫一個print each時,卻只會印印少少幾行呢?
--
Sent from my Windows
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.110.158.25
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1459526667.A.AA0.html
→
04/02 00:07, , 1F
04/02 00:07, 1F
→
04/02 00:08, , 2F
04/02 00:08, 2F
→
04/02 00:10, , 3F
04/02 00:10, 3F
→
04/02 00:10, , 4F
04/02 00:10, 4F
→
04/02 09:38, , 5F
04/02 09:38, 5F
→
04/02 09:41, , 6F
04/02 09:41, 6F
→
04/02 09:41, , 7F
04/02 09:41, 7F
→
04/02 12:22, , 8F
04/02 12:22, 8F
→
04/02 12:23, , 9F
04/02 12:23, 9F
→
04/02 14:28, , 10F
04/02 14:28, 10F
討論串 (同標題文章)
Python 近期熱門文章
PTT數位生活區 即時熱門文章