Home > Net >  What is the best method to copy all matching text from a web page?
What is the best method to copy all matching text from a web page?

Time:10-24

Background I have a live web dashboard for ticket numbers and their status updates. Each update and case number are in separate rows on this web page. To make this dashboard useful, I have to save it as offline HTML and import it into excel to copy one row of data like all case numbers.

Goal How do I search for a matching string on a page and copy all to clipboard in separate lines? EG, all my case numbers match the first two digits like “12.......” If I can manage to figure that out, I can make use of text in tools easier like Trello etc.

CodePudding user response:

You could do something like this with Python:

import re
import requests

text = input("Enter text: ")

url = requests.get('https://stackoverflow.com/questions/69691849/what-is-the-best-method-to-copy-all-matching-text-from-a-web-page').text
page = re.findall(text, url)

for i in page:
    print(i)

I don't think you'd be able to copy all the output, however you could just copy the output from command prompt. It's unclear what you are trying to fully achieve here.

Output:

Output with array ( print(page) ):

  • Related