Answer the question
In order to leave comments, you need to log in
How to get the text of an element using selenium in python?
Hello everyone,
I am writing a parser for issuing google in python using selenium.
I need to parse JSON like this:
{"cl":12,"cr":3,"id":"JAoZEfikv3d7yM:","isu":"moistimidtran.blogspot.com","ity":"jpg","oh":334,"ou ":" farm4.static.flickr.com/3239/2594001090_b5b9fb0ef6.jpg ","ow":500,"pt":"moistimidtran: people walking down the street","rid":"Hu_70STTJA3k4M","ru": " moistimidtran.blogspot.com/2010/11/people-walking-... ","s":"people walking down the street","th":183,"tu":" https://encrypted-tbn1 .gstatic.com/images?q\u003dt... ","tw":275}
e = browser.find_elements_by_class_name('rg_meta')
for img in imgs:
print img.text
Answer the question
In order to leave comments, you need to log in
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()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question