Last active
June 27, 2024 13:14
-
-
Save jduckles/9afc950aa88c474c1c111ff50c0553e9 to your computer and use it in GitHub Desktop.
Takes a URL and grabs the <title></title> contents to provide a Markdown Link using the title of the page. Used as a TextExpander Shortcut to paste links into Markdown Files with the page title as the link text.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Python Script to pull down title of web page and enter it into a markdown snippet. | |
~/bin/url2mdlink.py %clipboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python3 | |
from bs4 import BeautifulSoup | |
import lxml | |
import requests | |
import sys | |
url = sys.argv[1] | |
soup = BeautifulSoup(requests.get(url).text, 'lxml') | |
title = soup.title.string | |
print('[{title}]({url})'.format(title=title, url=url)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment