Extracting a specific string from a string

Asked 2 years ago, Updated 2 years ago, 103 views

Hello,

I'm going to take the date data from the title of the post

The output value of the title of the post using Beautifulsoup is as follows. "\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t From these string data, I'd like to have you collect it automatically in the form of "xxx"xxx year xxx" here, so what method should I use?

I don't think split or sliding methods should change the format of the title a little bit Is there a way to extract only the format like "%d%d%d%d year%d%d month%d"?

python crawling parsing

2022-09-20 16:38

1 Answers

l = re.foundall(r'(\d{4})year(\d{1,2})month(\d{1,2})day', 'string data')

I think I can do it like thisYo


2022-09-20 16:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.