Yotter icon indicating copy to clipboard operation
Yotter copied to clipboard

error on getTwitterUserInfo

Open rachmadaniHaryono opened this issue 3 years ago • 3 comments

Error function getTwitterUserInfo

environment

  • OS: Ubuntu 20.04.1 LTS x86_64
  • Python 3.8.2
  • Flask 1.1.2
  • Werkzeug 1.0.1

Steps to reproduce

  • flask run
  • browser normally

Expected behaviour

no error happened on console

Actual behaviour

Error

[2020-09-19 16:35:30,756] ERROR in app: Exception on /favicon.ico [GET]
Traceback (most recent call last):
  File "/home/r3r/envs/Yotter/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/r3r/envs/Yotter/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/r3r/envs/Yotter/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/r3r/envs/Yotter/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/r3r/envs/Yotter/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/r3r/envs/Yotter/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/r3r/envs/Yotter/lib/python3.8/site-packages/flask_login/utils.py", line 272, in decorated_view
    return func(*args, **kwargs)
  File "/home/r3r/git/Yotter/app/routes.py", line 186, in u
    user = getTwitterUserInfo(username)
  File "/home/r3r/git/Yotter/app/routes.py", line 605, in getTwitterUserInfo
    if html.find('a', attrs={'class':'profile-card-fullname'}):
AttributeError: 'NoneType' object has no attribute 'find'

notes

as temporary fix i use this

temp fix

From ed931a8dbe6040e791f7ed5fcd0976cc002c7e7d Mon Sep 17 00:00:00 2001
From: rachmadaniHaryono <[email protected]>
Date: Sat, 19 Sep 2020 17:40:17 +0800
Subject: [PATCH] fix: dev: getTwitterUserInfo

---
 app/routes.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/routes.py b/app/routes.py
index 8dda958..59aa827 100644
--- a/app/routes.py
+++ b/app/routes.py
@@ -602,7 +602,7 @@ def getTwitterUserInfo(username):
     else:
         html = html.body.find('div', attrs={'class':'profile-card'})

-        if html.find('a', attrs={'class':'profile-card-fullname'}):
+        if html and html.find('a', attrs={'class':'profile-card-fullname'}):
             fullName = html.find('a', attrs={'class':'profile-card-fullname'}).getText().encode('latin1').decode('unicode_escape').encode('latin1').decode('utf8')
         else:
             fullName = None
--
2.25.1

rachmadaniHaryono avatar Sep 19 '20 09:09 rachmadaniHaryono

Thank you for reporting. Can you tell me which user you were trying to visit?

pluja avatar Sep 19 '20 15:09 pluja

https://yotter.xyz/favicon.ico should be able to reproduce it

FireMasterK avatar Sep 19 '20 15:09 FireMasterK

Oh, I see. Thank you.

pluja avatar Sep 20 '20 07:09 pluja