'How do I click on this link inside a list? I'm scrapping yelp, using python. And Im trying to open specific links in a new tab but it won't open
Good Morning,
This is probably a really simple question. It's just harder for me because I'm still a baby programmer.
I'm trying to open up each link in this list. But the way I'm trying is not working. And another way that another user was trying to teach me didn't work. How do I fix this so that It opens in a new tab. Or please just show me how to click it. Thank you.
Here is all of the code.
count = 0
all_links = []
#yelp page
driver.get("https://yelp.com")
#Selecting the first box
type_of_food = driver.find_element_by_id('find_desc')
#Enter Chinese Food
type_of_food.send_keys('Chinese Food')
#press enter
driver.implicitly_wait(30)
#Button click
driver.find_element_by_id("header-search-submit").click()
driver.implicitly_wait(9)
dumplings = driver.find_elements_by_partial_link_text('Dumpling')
for item in dumplings:
all_links.append(item.get_attribute('href'))
print(all_links)
# this line of code doesn't work
ActionChains(driver).key_down(Keys.CONTROL).click(item).key_up(Keys.CONTROL).perform()
for item in dumplings:
print(item)
all_links.[count].click()
count = count + 1
I also tried to click in the line before the last but that didn't work. What should I do?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
