大家好:D
python自学新手,遇到问题想请教一下
from bs4 import BeautifulSoup as bs
import requests
req =
requests.get('http://mops.twse.com.tw/mops/web/t164sb04?encodeURIComponent=1&s
tep=1&firstin=1&off=1&keyword4=&code1=&TYPEK2=&checkbtn=&queryNa
me=co_id&TYPEK=all&isnew=true&co_id=2330&year=104&season=04')
req.encoding ='utf-8'
soup =bs(req.text,'html5lib')
table = soup.find('table', {'class': 'hasBorder'})
title =[]
num =[]
#print (table)
for tr in table.select('tr') :
if len (tr.select('td')) >0:
sub = (tr.select('td')[0].text)
subb=sub.replace('\u3000', '')
title.append(subb)
numm= str((tr.select('td')[1].text))
numm.replace(' ','')
num.append(numm)
print (num)