我到处研究过,我遇到了麻烦......我想访问每个单独的元素并将值附加到我的空python列表中......当然,在我的python列表中有正确的数据之后我要将它们附加到csv文件......
from urllib.request import urlopen
from bs4 import BeautifulSoup
import csv
html = urlopen("http://exoweb0.donbest.com/checkHTML/servlet/send_archive_history.servlet?by_casino=1&for_casino=37&league=1&game=0&date=20151029")
soup = BeautifulSoup((html), "html.parser")
trs = soup.findAll("tr")
dates = []
rotations = []
games = []
lines = []
types = []
for tr in trs.children:
print(tr)
#tds = tr.findAll("td") 'Finds all tds in current tr
#print (tds)
#date = tds.contents[0] ' It reference the first element in each td
#rot = tds[2] ' It reference the third element in each td
#game = tds[3] ' It reference the fourth element in each td
#line = tds[4] ' It reference the fith element in each td
#type_l = tds[5] ' It reference the sixth element in each td
#dates.append(date) Trying to append to my empty list
#rotations.append(rot)
#games.append(game)
#lines.append(line)
#types.append(type_l)