AttributeError: 'NoneType' object has no attribute 'group'
See original GitHub issueDescription of the problem
when running this examle code i can’t login and get errors.
Code to reproduce
# Example code
from fbchat import Client
from fbchat.models import *
import logging
logging.basicConfig(level=logging.DEBUG)
client = Client('<mail>', '<pwd>')
print(client.uid)
client.logout()
Traceback
Logging in mhem2014@yahoo.com...
INFO:client:Logging in mhem2014@yahoo.com...
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): m.facebook.com:443
DEBUG:urllib3.connectionpool:https://m.facebook.com:443 "GET / HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://m.facebook.com:443 "POST /login.php?login_attempt=1 HTTP/1.1" 302 0
DEBUG:urllib3.connectionpool:https://m.facebook.com:443 "GET /login/save-device/?login_source=login&refsrc=https%3A%2F%2Fwww.facebook.com%2F&_rdr HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://m.facebook.com:443 "GET /login/save-device/cancel/ HTTP/1.1" 302 0
DEBUG:urllib3.connectionpool:https://m.facebook.com:443 "GET /?_rdr HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): www.facebook.com:443
DEBUG:urllib3.connectionpool:https://www.facebook.com:443 "GET / HTTP/1.1" 200 0
Attempt #1 failed, retrying
Traceback (most recent call last):
File "C:\Users\el safer\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fbchat\_client.py", line 209, in login
user_agent=user_agent,
File "C:\Users\el safer\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fbchat\_state.py", line 149, in login
return cls.from_session(session=session)
File "C:\Users\el safer\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fbchat\_state.py", line 186, in from_session
fb_dtsg = FB_DTSG_REGEX.search(r.text).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
ERROR:client:Attempt #1 failed, retrying
Traceback (most recent call last):
File "C:\Users\el safer\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fbchat\_client.py", line 209, in login
user_agent=user_agent,
File "C:\Users\el safer\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fbchat\_state.py", line 149, in login
return cls.from_session(session=session)
File "C:\Users\el safer\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fbchat\_state.py", line 186, in from_session
fb_dtsg = FB_DTSG_REGEX.search(r.text).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
Environment information
- Python version:3.7.0
fbchat
version:1.9.6- If relevant, output from
$ python -m pip list
absl-py 0.9.0
aenum 2.2.3
aiohttp 3.5.4
alabaster 0.7.12
altgraph 0.16.1
amazonify 0.1
appdirs 1.4.3
Appium-Python-Client 0.50
APScheduler 3.6.3
asn1crypto 0.24.0
astor 0.8.1
async-timeout 3.0.1
attrs 19.3.0
auto-py-to-exe 2.6.1
Automat 20.2.0
Babel 2.7.0
backcall 0.1.0
beautifulsoup4 4.6.3
bottle 0.12.16
bottle-websocket 0.2.9
bs4 0.0.1
cachetools 4.1.0
certifi 2018.8.24
cffi 1.12.3
chardet 3.0.4
Click 7.0
clipboard 0.0.4
cloudmersive-convert-api-client 2.4.3
cloudmersive-image-api-client 2.1.5
cloudmersive-ocr-api-client 2.2.1
cloudmersive-validate-api-client 2.1.2
colorama 0.4.1
ConfigArgParse 0.11.0
configparser 3.7.4
constantly 15.1.0
cryptography 2.7
cssselect 1.0.3
cycler 0.10.0
Cython 0.29.16
decorator 4.4.2
distlib 0.3.0
distro 1.5.0
Django 2.2.2
dnspython 1.16.0
docutils 0.14
Eel 0.10.4
entrypoints 0.3
et-xmlfile 1.0.1
eventlet 0.25.0
fake-useragent 0.1.11
fbchat 1.9.6
filelock 3.0.12
flake8 3.7.7
Flask 1.0.2
Flask-MySQL 1.5.1
Flask-SocketIO 4.1.0
Flask-WTF 0.14.2
freelancersdk 0.1.20
future 0.16.0
gast 0.3.3
geographiclib 1.49
geopy 1.19.0
gevent 1.4.0
gevent-websocket 0.10.1
google-api-core 1.17.0
google-api-python-client 1.8.2
google-auth 1.14.0
google-auth-httplib2 0.0.3
google-cloud-vision 1.0.0
google-search-results 1.8.1
googleapis-common-protos 1.51.0
googletrans 2.4.0
greenlet 0.4.15
grpcio 1.28.1
guzzle-sphinx-theme 0.7.11
h5py 2.10.0
hangups 0.4.9
html5lib 1.0.1
httplib2 0.17.3
hyperlink 19.0.0
idna 2.7
imagecodecs 2020.2.18
imageio 2.8.0
imagesize 1.1.0
importlib-metadata 1.6.0
imutils 0.5.3
incremental 17.5.0
instagram-private-api 1.6.0.0
InstagramAPI 1.0.2
instaloader 4.3.1
ipython 7.14.0
ipython-genutils 0.2.0
itsdangerous 1.1.0
jdcal 1.4.1
jedi 0.17.0
Jinja2 2.10.1
joblib 0.15.1
kamene 0.32
Keras 2.0.8
Keras-Applications 1.0.8
Keras-Preprocessing 1.1.2
kiwisolver 1.1.0
lanscan 0.9.5
lml 0.0.9
lxml 4.3.3
macholib 1.11
Markdown 3.2.2
MarkupSafe 1.1.1
matplotlib 3.1.1
mccabe 0.6.1
MechanicalSoup 0.6.0
mechanize 0.4.2
monotonic 1.5
moviepy 0.2.3.2
mpegdash 0.2.0
multidict 4.5.2
mysql-connector 2.2.9
mysql-connector-python 8.0.15
netaddr 0.7.19
netifaces 0.10.9
networkx 2.4
nltk 3.4.4
nose 1.3.7
numpy 1.16.3
opencv-python 4.1.1.26
openpyxl 2.6.2
packaging 19.0
paho-mqtt 1.5.0
pandas 0.24.2
parse 1.12.0
parsel 1.5.2
parso 0.7.0
pbkdf2 1.3
pdf2image 1.12.1
pdfminer.six 20200517
pdftotree 0.4.0
pefile 2018.8.8
pickleshare 0.7.5
Pillow 6.0.0
pip 18.0
pocketsphinx 0.1.15
prompt-toolkit 3.0.5
Protego 0.1.16
protobuf 3.6.1
py2exe 0.9.2.0
pyaaf2 1.4.0
pyaes 1.6.1
pyasn1 0.4.8
pyasn1-modules 0.2.8
pyavb 0.1.0.dev2
pycodestyle 2.5.0
pycparser 2.19
pycryptodome 3.9.7
PyDispatcher 2.0.5
pyee 6.0.0
pyexcel 0.5.13
pyexcel-io 0.5.17
pyflakes 2.1.1
pygame 1.9.4
Pygments 2.4.2
PyHamcrest 2.0.2
PyInstaller 3.6
PyMySQL 0.9.3
pynput 1.4.2
pyOpenSSL 19.0.0
pyparsing 2.4.0
PyPDF2 1.26.0
pyperclip 1.8.0
pyppeteer 0.0.25
PyQt5 5.13.0
PyQt5-sip 12.7.2
pyqt5-tools 5.13.0.1.5
pyquery 1.4.0
Pyrogram 0.17.0.dev0
pyserial 3.4
PySocks 1.7.0
pyTelegramBotAPI 3.6.7
pytesseract 0.3.3
python-dateutil 2.8.0
python-dotenv 0.13.0
python-engineio 3.8.2
python-nmap 0.6.1
python-socketio 4.2.0
python-telegram 0.11.0
python-telegram-bot 12.4.2
pyttsx3 2.7
pytz 2019.1
pyusb 1.0.2
PyWavelets 1.1.1
pywin32 223.1
pywin32-ctypes 0.2.0
PyX 0.15
PyYAML 5.1.1
queuelib 1.5.0
readlike 0.1.2
ReParser 1.4.3
requests 2.23.0
requests-file 1.4.3
requests-html 0.10.0
requests-toolbelt 0.7.0
rsa 4.0
scapy 2.4.3
scapy-python3 0.26
schedule 0.6.0
scikit-image 0.17.2
scikit-learn 0.23.1
scipy 1.4.1
Scrapy 2.0.1
selectivesearch 0.4
selectorlib 0.16.0
selenium 3.141.0
selenium-requests 1.3
seleniumbot 0.1
service-identity 18.1.0
setuptools 39.0.1
six 1.12.0
sklearn 0.0
snowballstemmer 1.9.0
sortedcontainers 2.1.0
SpeechRecognition 3.8.1
Sphinx 2.1.2
sphinxcontrib-applehelp 1.0.1
sphinxcontrib-devhelp 1.0.1
sphinxcontrib-htmlhelp 1.0.2
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-qthelp 1.0.2
sphinxcontrib-serializinghtml 1.1.3
sqlparse 0.3.0
statistics 1.0.3.5
tabula-py 2.1.0
telebot 0.0.3
tensorboard 1.12.2
tensorflow 1.12.0
termcolor 1.1.0
tesseract 0.1.3
texttable 1.6.1
TgCrypto 1.2.0
threadpoolctl 2.0.0
tifffile 2020.5.11
tldextract 2.2.1
tornado 6.0.4
tqdm 4.11.2
traitlets 4.3.3
trunofficial 0.2.4
Twisted 20.3.0
tzlocal 2.0.0
UNKNOWN 0.0.0
uritemplate 3.0.1
urllib3 1.23
urwid 1.3.1
virtualenv 20.0.18
w3lib 1.20.0
Wand 0.6.1
wcwidth 0.1.9
webencodings 0.5.1
websocket-client 0.56.0
websockets 7.0
Werkzeug 0.15.2
wheel 0.34.2
whichcraft 0.5.2
wifi 0.3.8
WTForms 2.2.1
xlrd 1.2.0
XlsxWriter 1.2.8
xlutils 2.0.0
xlwt 1.3.0
xmltodict 0.12.0
yarl 1.3.0
zipcodes 1.0.5
zipp 3.1.0
zope.interface 5.0.2
If you have done any research, include that. Yes i have done a research but the errors seems to be old. i am using IDLE btw.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:13
Top Results From Across the Web
Python regex AttributeError: 'NoneType' object has no attribute ...
I managed to figure out this solution: omit group() for the situation where the searchbox reply is "No results" and thus doesn't match...
Read more >[Solved] AttributeError: Nonetype Object Has No Attribute Group
“AttributeError Nonetype object has no attribute group” is the error raised by the python interpreter when it fails to fetch or access ...
Read more >AttributeError: 'NoneType' object has no attribute 'group'
The Python "AttributeError: 'NoneType' object has no attribute" occurs when we try to call the group() method on a None value, ...
Read more >How To Fix Error: 'NoneType' Object Has No Attribute 'Group'?
Summary: NoneType attribute error occurs when the type of object being referenced is ... AttributeError: 'tuple' object has no attribute 'insert'.
Read more >'NoneType' object has no attribute 'group' · Issue #349 - GitHub
Environment. Describe here your environment, including: MacOS Monterrey v12.1. Python 3.3.9. Error description - installation.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Can confirm it works with the old facebook… Hope an update soon to support the new one.
You can do that by passing an OLD user agent :
client = Client(login, password, user_agent="Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko")
I’m trying to figure out what is happening.
In fact in _state.py ; from_session method a “get” on facebook.com return a 200 response but with empty content (Content-Length = 0) : This is not a normal thing, Facebook should return the home page with the login fields.