Reputation: 147
Thanks for the help with the previous, a bit longer problem @QHarr and @DebanjanB
This one is uncomplicated and comes from me being a total beginner.
I need to scrape the image location from this snippet from webauto.de + a click on the gallery
<li class="slide" style="">
<img class="image" src="https://www.webauto.de/img/vc/de/0/1/2/19482/pan/1735h_1" style="max-width: 640px; max-height: 480px; width: 100%; height: auto; left: 50%; top: 50%; margin-left: -320px; margin-top: -240px;" alt=""></li>
And either
find_elements_by_css_selector('.slide > img')
find_elements_by_css_selector('li > img')
find_elements_by_xpath("//li[@class='slide']/img]"
leaves me with a blank list instead of a list of addressess.
The second thing is I need to select a subgroup from a JS dropdown on hasznaltauto.hu
<select id="hirdetesszemelyautosearch-modell_id" class="form-control hidegroups" name="HirdetesSzemelyautoSearch[modell_id]" data-live-search="false" data-header="Modell" data-krajee-depdrop="depdrop_fdcef640" disabled="disabled">
<optgroup label="FIESTA">
<option value="540" class="opt">FIESTA (1001)</option></optgroup>
And I used a logical continuation of what was provided to me but but it throws 'tuple index out of range'
find_element_by_xpath("//select[@id='hirdetesszemelyautosearch-modell_id']/optgroup[@label='{}']/option[contains(text(), '{}')]".format('FIESTA')).click()
Upvotes: 1
Views: 137
Reputation: 19154
for full size image you need extract it in iframe
iframe = WebDriverWait(driver, 15).until(EC.presence_of_element_located((By.ID, "sb-player")))
driver.switch_to.frame(iframe)
images = driver.find_elements_by_css_selector('.slide > img')
Upvotes: 1
Reputation: 84465
You could use a CSS selector to grab all the image links. I wasn't sure what you meant by address but have used class selector to grab address under gallery.
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
d = webdriver.Chrome()
d.get("https://www.webauto.de/site/de/auto-detail/v-id/121078258-1/fahrzeug/FORD-Fiesta-Style-1,3l-44kW-5-Gang-!-Nur-an-Gewerbe/Export-!-/Gebrauchtwagen/Limousine/silber/Benzin/44-KW-60-PS/Wesseling")
elements = WebDriverWait(d,5).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "[src^='https://www.webauto.de/img/']")))
linkList = [element.get_attribute('src') for element in elements]
print(linkList)
print(d.find_element_by_css_selector('.contactdata').text)
#d.quit()
Upvotes: 1