So I'm using Selenium (Firefox WebDriver) in Python to go to a link, login, then go to another page after login.
On this page is a grid of items. Each item has 3 subitems: link (the item is clickable), image, and title (like a description).
I'm able to pull all the items using a for-in loop into a variable. Then I just do all_items[:3] to get the first 3. However I can't figure out how to further narrow it by grabbing all_items[2] 's image only. Basically I want to organize it into a two-dimensional array if I'm understanding it correctly.
My end goal is to be able to do these outputs(not actual code):
4 being item #4, 2 being the image subitem of the 3 (link, image, title)
I've been googling for a while. I've been working on this personal project for a bit now and I've made good progress for the little Python I know and I've managed to get a lot of progress thanks to researching. However, I'm stuck on this part and can't figure it out.
I have two versions I've been messing with but can't figure out how to go further.
V1 - I found similar code to this online and modified it to work for my use. This is the farthest I can get in terms of controlling the index. I'm able to call items[:3] for the first 3 items but I can't control the subitems.
V2 - This probably would work better than V1 but I can't figure out how to throw it into a two-dimensional array now. It does output it how I want but I can't control which item index it outputs.
Any help would be greatly appreciated. Thanks a bunch!
On this page is a grid of items. Each item has 3 subitems: link (the item is clickable), image, and title (like a description).
I'm able to pull all the items using a for-in loop into a variable. Then I just do all_items[:3] to get the first 3. However I can't figure out how to further narrow it by grabbing all_items[2] 's image only. Basically I want to organize it into a two-dimensional array if I'm understanding it correctly.
My end goal is to be able to do these outputs(not actual code):
Code
all_items[4][2] = https://example.com/image.png
all_items[4] = 'https://example.com/home.html', 'https://example.com/image.png', 'Welcome to Example!'4 being item #4, 2 being the image subitem of the 3 (link, image, title)
I've been googling for a while. I've been working on this personal project for a bit now and I've made good progress for the little Python I know and I've managed to get a lot of progress thanks to researching. However, I'm stuck on this part and can't figure it out.
I have two versions I've been messing with but can't figure out how to go further.
V1 - I found similar code to this online and modified it to work for my use. This is the farthest I can get in terms of controlling the index. I'm able to call items[:3] for the first 3 items but I can't control the subitems.
Code
items = [{"Link": item.find_element_by_class_name('ember-view').get_attribute('href'), "Title": item.find_element_by_class_name('achievement-title').text, "Image": item.find_element_by_class_name('main-image').get_attribute('src')} for item in all_items]V2 - This probably would work better than V1 but I can't figure out how to throw it into a two-dimensional array now. It does output it how I want but I can't control which item index it outputs.
Code
for item in all_items:
item_link = [item.find_element_by_class_name('ember-view').get_attribute('href')]
item_title = [item.find_element_by_class_name('achievement-title').text]
item_image = [item.find_element_by_class_name('main-image').get_attribute('src')]
print(item_link + item_title + item_image)Any help would be greatly appreciated. Thanks a bunch!


![[Image: support1.png]](https://hackforums.news/assets/v5/support1.png)
