I have the following code:
sauce = urllib.request.urlopen('https://www.iproperty.com.my/sale/selangor/all-commercial/?q=UOA%20Business%20Park').read()
soup = bs.BeautifulSoup(sauce,'html.parser')
price = soup.find_all('ul',class_='listing-primary-price jMWEse')
BUA = soup.find_all('li',class_='attributes-price-per-unit-size-item builtUp-attr fsbnan')
for data in price:
Price = data.text
print(Price)
for data in BUA:
BUA = data.text
print(BUA)
printing Price and BUA gives me the following results:
Price:
RM 1,067,490
RM 2,246,160
RM 929,160
RM 1,321,000
RM 103,840,000
BUA:
Built-up : 1,227 sq. ft.Built-up : 1,227 sq. ft.
Built-up : 2,292 sq. ft.Built-up : 2,292 sq. ft.
Built-up : 1,044 sq. ft.Built-up : 1,044 sq. ft.
Built-up : 1,335 sq. ft.Built-up : 1,335 sq. ft.
Built-up : 118,000 sq. ft.Built-up : 118,000 sq. ft.
My questions is, how can I load Price and BUA into a Pandas Dataframe because I would like to join the both of them and print an end result with something like:
Price: BUA:
0 RM 1,067,490 Built-up : 1,227 sq. ft.Built-up : 1,227 sq. ft.
1 RM 2,246,160 Built-up : 2,292 sq. ft.Built-up : 2,292 sq. ft.
2 RM 929,160 Built-up : 1,044 sq. ft.Built-up : 1,044 sq. ft.
3 RM 1,321,000 Built-up : 1,335 sq. ft.Built-up : 1,335 sq. ft.
4 RM 103,840,000 Built-up : 118,000 sq. ft.Built-up : 118,000 sq. ft.
Another reason why I want to put them into a Pandas Dataframe is because I need to do some calculations in Excel later on.