[問題] 網頁原始碼抓資料問題
小弟想要抓取網頁某個值...
但如果從網頁原始碼抓會有很多相同的TAG
請問我如何抓到第N個TAG的值呢??
例如:
<td align="center" bgcolor="#FFFfff" nowrap>100</td>
<td align="center" bgcolor="#FFFfff" nowrap>200</td>
<td align="center" bgcolor="#FFFfff" nowrap>300</td>
<td align="center" bgcolor="#FFFfff" nowrap>400</td>
我用search 抓都只能抓到第一個值"100":
number = re.compile( r'nowrap>(.+)</td>.*', re.I | re.U | re.M)
content = opener.open('http://www.xxx.com.tw').read()
value = number.search( content ).groups()[ 0 ]
請問我要修改那裡??或者有其他較好用的function嗎??
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.195.207.241
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1430832630.A.A3F.html
→
05/05 23:44, , 1F
05/05 23:44, 1F
→
05/06 14:26, , 2F
05/06 14:26, 2F
→
05/06 14:28, , 3F
05/06 14:28, 3F