I'm trying to convert scraped data to a pd dataframe(table). The info is retrieved via beautifulsoup from different tags (a, span, div). for ul in soup_level1.find('ul', {'class':"fix3"}):
divjt=ul.find('div',{'class':"topb"})
a=divjt.find('a')
trajectory=a.text.strip()
divloc=ul.find('div',{'class':"under"})
d=divloc.find('div')
sp=ul.find('span',{'class':"blk"})
object=sp.text.strip()
try:
sas=ul.find_all('span',{'class':"f1"})
timex=sas[0].text
except IndexError:
timex=''
datalist.append[jobtitle,city,timex]
headers=['Traj', 'Object', 'Time']
A=[trajectory]
B=[object]
C=[timex]
datac=A+B+C
df = pd.DataFrame(datac)
print(df)
The result I am getting right now is
0
0 BRD - TWD
1 MER
2 11/10/2018
0
0 SFX - NYT
1 MER
2 10/05/2016
0
0 GER - BEN
1 MER
2 05/06/2016
I would basically want to "dump" those results in a proper dataframe table where each row is printed to excel accordingly.
0 BRD - TWD MER 11/10/2018
1 SFX - NYT MER 10/05/2016
2 GER - BEN MER 05/06/2016
Thank you!