Could someone check the code and show me my mistake:
Can not create dictionary with all results. if I check
for i in boxes:
print(i.text)
I get the list with data what I am looking for. If I want to "split" it for parsing, then I get same number of results, but value is the same for all results. For example I get 20 lines of the same data.
url = 'https://www.willhaben.at/iad/immobilien/eigentumswohnung/eigentumswohnung-angebote?sfId=79dc800d-b672-43d4-910f-b5a2dfdb6b1a&isNavigation=true&areaId=900&rows=25&NO_OF_ROOMS_BUCKET=3X3&page=5&ESTATE_SIZE/LIVING_AREA_FROM=65&PRICE_TO=365000'
boxes = driver.find_elements('css selector',
"div[class='Box-sc-wfmb7k-0 jYFQjC']"
)
for item in boxes:
question = {
'title' : driver.find_element('css selector',
"div[class='Box-sc-wfmb7k-0 dZUXGn']"
).get_attribute('innerHTML').strip(),
'link' : driver.find_element('css selector',
"a[class='AnchorLink__StyledAnchor-sc-1ep83ox-0 inWMrO ResultListAdRowLayout___StyledClientRoutingAnchorLink-sc-1rmys2w-1 houIJO']"
).get_attribute('href'),
'size' : driver.find_element('xpath',
"//div/a/div[3]/div[1]/div[1]/span[1]"
).get_attribute('innerHTML').strip()
}
list_wohnung.append(question)
CodePudding user response:
'title' : item.find_element('css selector',
"div[class='Box-sc-wfmb7k-0 dZUXGn']"
).get_attribute('innerHTML').strip(),
Find from current item and not driver.