爬蟲網址:
https://fubon-ebrokerdj.fbs.com.tw/z/zg/zgb/zgb0.djhtm?a=1160&b=1163&c=E&d=1
使用下面語法爬蟲 (語法自己摸索可能寫的不是很好,也可以指正)
def get_NBA(url):
r = requests.get(url=url)
r.encoding = 'big5'
if r.status_code == requests.codes.ok:
soup = BeautifulSoup(r.text, 'html.parser')
for tr in soup.find_all('tr'):
for td in tr.findAll('td'):
text = '#'+td.getText()
file.write(text)
file.write('#EENNDD\n')
#file.write('\n')
結果遇到他在主要股號股名那邊我就抓不到了
<tr>
<td class="t4t1" nowrap id="oAddCheckbox">
<SCRIPT LANGUAGE=javascript>
<!--
GenLink2stk('AS2834','臺企銀');
//-->
</SCRIPT>
</td>
<td class="t3n1" nowrap>215</td>
<td class="t3n1" nowrap>9</td>
<td class="t3n1" nowrap>206</td>
</tr>
<!--
GenLink2stk('AS2834','臺企銀');
//-->
這三行不會抓到
不知是否有方法可以爬到
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.219.174.97 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1658718317.A.DF5.html
→
07/25 11:34,
1年前
, 1F
07/25 11:34, 1F
→
07/25 15:51,
1年前
, 2F
07/25 15:51, 2F
→
07/25 17:20,
1年前
, 3F
07/25 17:20, 3F
推
07/25 17:25,
1年前
, 4F
07/25 17:25, 4F
→
07/26 09:26,
1年前
, 5F
07/26 09:26, 5F