Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - trigger: :test
- replace: '{{Clipb}} {{Output}}'
- vars:
- - name: Clipb
- type: clipboard
- - name: Output
- type: script
- params:
- args:
- - python
- - -c
- - |
- import sys
- from PyQt5.QtWidgets import QApplication
- from bs4 import BeautifulSoup
- def extract_urls_from_html(html_content):
- soup = BeautifulSoup(html_content, 'html.parser')
- anchors = soup.find_all('a')
- urls = [a['href'] for a in anchors if a.get('href')]
- return urls
- def main():
- app = QApplication(sys.argv)
- clipboard = app.clipboard()
- mime_data = clipboard.mimeData()
- if mime_data.hasHtml():
- html_content = mime_data.html()
- urls = extract_urls_from_html(html_content)
- if urls:
- for url in urls:
- print(url)
- else:
- print("No URLs found in clipboard content.")
- else:
- print("Clipboard does not contain HTML content.")
- # You don't need to run the main loop of the QApplication, so we can exit here.
- sys.exit()
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement