I am using the Beautiful Soup package to do some webscraping and I want to be able to put lines into a dictionary, named table, where each key will have multiple values.
This dictionary is representative of a table and will eventually be made into a table
I have scraped the html to provide me with the key values, but the issue is reading the next line from the html and matching with correct key.
These names are the dictionary key names:
RowName
UpdateTime
State
OrdersC
TicketsR
OrdersNC
TicketsNR
ReadingTime
ClearingTime
ClearingInProgress
Volumes
StartTime
StopTime
This is how the data looks (when printed to console):
(NOTE: There will be more than two of these result sets)
NYBOT
00:10:39
Not Connected
0
7043
0
7043
07:58:30
--:--:--
0
0
02:30:00
20:00:00
MONTREAL
N/A
N/A
0
145
0
145
07:59:01
--:--:--
0
0
01:00:00
20:00:00
So the dictionary will look like:
{RowName: [NYBOT, MONTREAL], UpdateTime: [00:10:39, N/A], ... , StopTime: [20:00:00,20:00:00]}
I have tried this, but to no avail as the error I get is that the next() function cannot iterate over strings:
for line in site.find_all('td'):
line = line.strip()
table.update(RowName = line.text.replace('\xa0', ''))
next(line)
.
.
.
next(line)
table.update(StopTime = line.text.replace('\xa0', ''))