hdhudhefzwhreu

remotes/1693045480750635534/spooky-22
fireworks88 2021-10-27 11:29:45 +02:00
parent 0872305041
commit 59234e54ff
1 changed files with 4 additions and 4 deletions

View File

@ -866,20 +866,20 @@ def submit_post(v):
# archive other urls in post # archive other urls in post
url_regex = '<a (target=\"_blank\" )?(rel=\"nofollow noopener noreferrer\" )?href=\"(https?://[a-z]{1,20}\.[^\"]+)\"( rel=\"nofollow noopener noreferrer\" target=\"_blank\")?>([^\"]+)</a>' url_regex = '<a (target=\"_blank\" )?(rel=\"nofollow noopener noreferrer\" )?href=\"(https?://[a-z]{1,20}\.[^\"]+)\"( rel=\"nofollow noopener noreferrer\" target=\"_blank\")?>([^\"]+)</a>'
_body = new_post.body_html _body = new_post.body_html
print(_body) #print(_body)
for url_match in re.finditer(url_regex, _body, flags=re.M|re.I): for url_match in re.finditer(url_regex, _body, flags=re.M|re.I):
href = url_match.group(3) href = url_match.group(3)
if not href: if not href:
print(f'{url_match.group(0)} skip') #print(f'{url_match.group(0)} skip')
continue continue
print(href) #print(href)
title = url_match.group(5) title = url_match.group(5)
body += f'**[{title}]({href})**:\n\n' body += f'**[{title}]({href})**:\n\n'
body += f'* [reveddit.com](https://reveddit.com/{href})\n' body += f'* [reveddit.com](https://reveddit.com/{href})\n'
body += f'* [archive.org](https://web.archive.org/{href})\n' body += f'* [archive.org](https://web.archive.org/{href})\n'
body += f'* [archive.ph](https://archive.ph/?url={quote(href)}&run=1) (click to archive)\n' body += f'* [archive.ph](https://archive.ph/?url={quote(href)}&run=1) (click to archive)\n\n'
gevent.spawn(archiveorg, href) gevent.spawn(archiveorg, href)
body_md = CustomRenderer().render(mistletoe.Document(body)) body_md = CustomRenderer().render(mistletoe.Document(body))