Check packages for broken links when submitting for approval

Half of #546
This commit is contained in:
rubenwardy
2024-07-04 21:29:56 +01:00
parent a38a650dc1
commit 3f62a41952
7 changed files with 91 additions and 6 deletions

View File

@@ -15,6 +15,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from functools import partial
from urllib.parse import urljoin
import bleach
from bleach import Cleaner
@@ -205,3 +206,9 @@ def get_user_mentions(html: str) -> set:
soup = BeautifulSoup(html, "html.parser")
links = soup.select("a[data-username]")
return set([x.get("data-username") for x in links])
def get_links(html: str, url: str) -> set:
soup = BeautifulSoup(html, "html.parser")
links = soup.select("a[href]")
return set([urljoin(url, x.get("href")) for x in links])