Python Forum
How to find tags using specific text (timestamps) in a url?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to find tags using specific text (timestamps) in a url?
#1
The tags are in the following format:

<pre>
<a href="../">../</a>
< a href="the text I want to extract" > the text I want to extract/</a>
" 29 - Nov - 2021 02:19 - "
5000 more tags in this format ....
</pre>

There are 5000 tags in this format, I am trying to extract the A tags based on the time stamps in the text after each tag. For example, all the tags that contain "29-Nov - 2021" in the text string.

Can I use beautiful soup to achive this?

Something like:

def time_in_text(tag):
return tag.name == 'a' and '29-Nov-2021' in tag.get_text()
Results= soup.find(time_in_text)
buran write Mar-08-2022, 08:02 AM:
Please, use proper tags when post code, traceback, output, etc. You already have been advised to do so in your first thread.
See BBcode help for more info.
Reply
#2
So, did it work, when you try BS4? If not - what was the problem, do you get any errors?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Find a specific keyword after another keyword and change the output sgtmcc 5 820 Oct-05-2023, 07:41 PM
Last Post: deanhystad
  Color a table cell based on specific text Creepy 11 1,993 Jul-27-2023, 02:48 PM
Last Post: deanhystad
  Pypdf2 will not find text standenman 2 939 Feb-03-2023, 10:52 PM
Last Post: standenman
  read a text file, find all integers, append to list oldtrafford 12 3,583 Aug-11-2022, 08:23 AM
Last Post: Pedroski55
  find some word in text list file and a bit change to them RolanRoll 3 1,533 Jun-27-2022, 01:36 AM
Last Post: RolanRoll
  Extracting Specific Lines from text file based on content. jokerfmj 8 2,997 Mar-28-2022, 03:38 PM
Last Post: snippsat
  Find and delete above a certain line in text file cubangt 12 3,488 Mar-18-2022, 07:49 PM
Last Post: snippsat
  Get text from within h3 html tags Pedroski55 8 4,299 Jan-05-2022, 06:50 AM
Last Post: Larz60+
  labels.append(self.classes.index(member.find('name').text)) hobbyist 1 1,922 Dec-15-2021, 01:53 PM
Last Post: deanhystad
Thumbs Up [SOLVED] Find last occurence of pattern in text file? Winfried 4 4,407 Aug-13-2021, 08:21 PM
Last Post: Winfried

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020