简体   繁体   中英

How can I get the text from an element without any class/id/whatever from a website w/ selenium python?

I need to get the string ': 1:30 pm' in the following piece of html code using python and selenium: https://gyazo.com/faa95c118c25db13f5f71361eb795d6c

I wouldn't know how to do it since it seems like I can't use anything to identify it.

Update bigger section of the html code: https://gyazo.com/dec5665f771945b7671ef6a811b08dfe

That is all I have, and I would need a program that returns me the string with the time, which changes everyday.

Without the entire file, it's hard to tell you the xpath to find that specific string. You could try getting the parent element's text and then using Python to extract the time.

my_str = 'Room: 105 Start Time: 1:30 pm'
my_time = my_str[my_str.index('Start Time: ') + len('Start Time: '):]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM