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

Asked 1 weeks ago, Updated 1 weeks ago, 1 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


© 2022 pinfo. All rights reserved.