import ast
from selenium import webdriver
wd = webdriver.Firefox()
wd.get('https://goo.gl/knrjOl')
all_pics = wd.find_elements_by_xpath("//div[@class='rg_meta']")
try:
for pic in all_pics:
a = ast.literal_eval(wd.execute_script("return arguments[0].innerHTML", pic))
if "ou" in a.keys():
print a["ou"]
finally:
wd.close()
wd.quit()
key_down(value, element=None)
Sends a key press only, without releasing it.
Should only be used with modifier keys (Control, Alt and Shift).
Args:
value: The modifier key to send. Values are defined in Keys class.
element: The element to send keys. If None, sends a key to current focused element.
Example, pressing ctrl+c:
ActionChains(driver).key_down(Keys.CONTROL).send_keys('c').key_up(Keys.CONTROL).perform()