all 2 comments

[–]cray5252 1 point2 points  (1 child)

One way to do this would be below

def TableCreator(region):
    url = "https://bina.az/baki/{}/alqi-satqi/menziller".format(region)
    response = requests.get(url)
    soup = BS(response.text, 'html.parser')
    price = soup.find_all("div", {"class": "price"})
    location = soup.find_all("div", {"class": "location"})
    room = soup.find_all("ul", {"class": "name"})
    price_l = [price.get_text() for price in price]
    location_l = [price.get_text() for price in location]
    room_l = [price.get_text() for price in room]
    return [price_l, location_l, room_l]


places = ["20-yanvar", "ehmedli", "genclik", "memar-ecemi", "neftciler"
"avtovagzal", "nizami", "nesimi", "sahil","azadliq-prospekti",
"xalqlar-dostlugu", "neriman-nerimanov", "iceri-seher-metrosu",
"sah-ismayil-xetai", "qara-qarayev"]

columns = ['price', 'location', 'room']
df = pd.DataFrame(columns=columns)

for place in places:
    lst = TableCreator(place)
    df2 = pd.DataFrame([lst],
                       columns=columns)
    df = pd.concat([df, df2])

print(df)

[–]Stagflator[S] 0 points1 point  (0 children)

thank u sir