Init
This commit is contained in:
commit
6bbbd129aa
|
@ -0,0 +1 @@
|
|||
token.dat
|
|
@ -0,0 +1,39 @@
|
|||
import sys
|
||||
import os.path as op
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from mastodon import Mastodon
|
||||
|
||||
URL_HEAD = 'https://anime-pictures.net'
|
||||
|
||||
def main():
|
||||
# Searching for the url of the highest rated art
|
||||
resp = requests.get(URL_HEAD)
|
||||
soup = BeautifulSoup(resp.text, 'lxml')
|
||||
final_url = URL_HEAD + str(soup.findAll('span', {'class': 'img_block2'})[12]).split('"')[5]
|
||||
print(final_url)
|
||||
|
||||
# Requesting its page and getting the actual full image
|
||||
resp = requests.get(final_url)
|
||||
soup = BeautifulSoup(resp.text, 'lxml')
|
||||
src_url = URL_HEAD + str(soup.find('div', {'id': 'big_preview_cont'})).split('"')[5]
|
||||
|
||||
src_ext = src_url.split('.')[-1]
|
||||
if src_ext == 'jpg':
|
||||
src_ext = 'jpeg'
|
||||
|
||||
# Logging in and posting
|
||||
mastodon = Mastodon(
|
||||
access_token = 'token.dat',
|
||||
api_base_url = 'https://udongein.xyz/'
|
||||
)
|
||||
|
||||
media = mastodon.media_post(requests.get(src_url).content, 'image/' + src_ext)
|
||||
toot = ':senko:\nurl: ' + final_url
|
||||
|
||||
mastodon.status_post(toot, media_ids=[media], visibility='unlisted', sensitive=False)
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
Loading…
Reference in New Issue