Python - When extracting content in a tag, how to extract numbers other than text?

Asked 2 years ago, Updated 2 years ago, 22 views

For example,

<`span class = "time> 18:00 ~ 22:00 </span> 

I'm trying to extract only the number (time) inside, but it doesn't work with my code.

My code is as follows.

job_time = job.find('td', {"class" : "data"}).find('span', 
{"class" : "time"}).text

It doesn't work with .text or .str, but is there any other way?

python

2022-09-20 11:41

1 Answers

job_time = re.sub(r'[^0-9]', '', job_time)


2022-09-20 11:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.