mirror of
https://gitlab.com/jeancf/twoot.git
synced 2024-11-27 14:01:13 +00:00
Put it in a function
This commit is contained in:
parent
17bbcb7372
commit
3583186d3f
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,6 +1,7 @@
|
||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
venv/
|
venv/
|
||||||
|
__pycache__/
|
||||||
*.secret
|
*.secret
|
||||||
*.sh
|
*.sh
|
||||||
*.log
|
*.log
|
||||||
|
|
28
twoot.py
28
twoot.py
|
@ -169,6 +169,16 @@ def build_config(args):
|
||||||
print('CRITICAL: Missing Mastodon user')
|
print('CRITICAL: Missing Mastodon user')
|
||||||
terminate(-1)
|
terminate(-1)
|
||||||
|
|
||||||
|
def update_profile(TOML, soup, db, mast_password):
|
||||||
|
# Extract avatar picture address
|
||||||
|
avatar_url = 'https://' + unquote(soup.find('div', class_='profile-card-info').findChild('a').findChild('img').get('src').removeprefix('/pic/'))
|
||||||
|
|
||||||
|
# Extract banner picture address
|
||||||
|
banner_url = unquote(soup.find('div', class_='profile-banner').findChild('a').findChild('img').get('src').removeprefix('/pic/'))
|
||||||
|
|
||||||
|
mastodon_account = TOML['config']['mastodon_user']
|
||||||
|
|
||||||
|
exit()
|
||||||
|
|
||||||
def deredir_url(url):
|
def deredir_url(url):
|
||||||
"""
|
"""
|
||||||
|
@ -750,22 +760,16 @@ def main(argv):
|
||||||
logging.debug('Nitter page downloaded successfully from ' + url)
|
logging.debug('Nitter page downloaded successfully from ' + url)
|
||||||
|
|
||||||
# DEBUG: Save page to file
|
# DEBUG: Save page to file
|
||||||
of = open(TOML['config']['twitter_account'] + '.html', 'w')
|
# of = open(TOML['config']['twitter_account'] + '.html', 'w')
|
||||||
of.write(twit_account_page.text)
|
# of.write(twit_account_page.text)
|
||||||
of.close()
|
# of.close()
|
||||||
|
|
||||||
# Make soup
|
# Make soup
|
||||||
soup = BeautifulSoup(twit_account_page.text, 'html.parser')
|
soup = BeautifulSoup(twit_account_page.text, 'html.parser')
|
||||||
|
|
||||||
# Extract avatar picture address
|
# Update profile if it has changed
|
||||||
avatar = 'https://' + unquote(soup.find('div', class_='profile-card-info').findChild('a').findChild('img').get('src').removeprefix('/pic/'))
|
# TODO Make conditional to TOML option
|
||||||
|
update_profile(TOML, soup, db, mast_password)
|
||||||
# Extract banner picture address
|
|
||||||
banner = unquote(soup.find('div', class_='profile-banner').findChild('a').findChild('img').get('src').removeprefix('/pic/'))
|
|
||||||
|
|
||||||
print(avatar)
|
|
||||||
print(banner)
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
# Extract twitter timeline
|
# Extract twitter timeline
|
||||||
timeline = soup.find_all('div', class_='timeline-item')
|
timeline = soup.find_all('div', class_='timeline-item')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user