Closed shmedd closed 9 months ago
Ok i will look into it
You need to set the variable for username and password with your account
There is another error that sometimes replaces the above one (most of the time actually) for no apparent reason. The error being inconsistent is making this hard to solve; it is:
PS C:\Users\a\b\c\d\marketwatch> & C:/Users/a/AppData/Local/Programs/Python/Python311/python.exe c:/Users/a/b/c/d/marketwatch/__init__.py
Traceback (most recent call last):
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore\_exceptions.py", line 10, in map_exceptions
yield
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore\_backends\sync.py", line 62, in start_tls
raise exc
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore\_backends\sync.py", line 57, in start_tls
sock = ssl_context.wrap_socket(
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1075, in _create
self.do_handshake()
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1346, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx\_transports\default.py", line 60, in map_httpcore_exceptions
yield
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx\_transports\default.py", line 218, in handle_request
resp = self._pool.handle_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore\_sync\connection_pool.py", line 262, in handle_request
raise exc
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore\_sync\connection_pool.py", line 245, in handle_request
response = connection.handle_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore\_sync\connection.py", line 92, in handle_request
raise exc
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore\_sync\connection.py", line 69, in handle_request
stream = self._connect(request)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore\_sync\connection.py", line 149, in _connect
stream = stream.start_tls(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore\_backends\sync.py", line 54, in start_tls
with map_exceptions(exc_map):
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 155, in __exit__
self.gen.throw(typ, value, traceback)
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore\_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ConnectError: [WinError 10054] An existing connection was forcibly closed by the remote host
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "c:\Users\a\b\c\d\marketwatch\__init__.py", line 63, in <module>
marketwatch = MarketWatch(username, password)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\a\b\c\d\marketwatch\marketwatch\__init__.py", line 55, in __init__
self.login()
File "c:\Users\a\b\c\d\marketwatch\marketwatch\__init__.py", line 139, in login
"_csrf": self.generate_csrf_token(),
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\a\b\c\d\marketwatch\marketwatch\__init__.py", line 67, in generate_csrf_token
client = self.session.get("https://sso.accounts.dowjones.com/login-page")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx\_client.py", line 1041,
in get
return self.request(
^^^^^^^^^^^^^
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx\_client.py", line 814, in request
return self.send(request, auth=auth, follow_redirects=follow_redirects)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx\_client.py", line 901, in send
response = self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx\_client.py", line 929, in _send_handling_auth
response = self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx\_client.py", line 966, in _send_handling_redirects
response = self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx\_client.py", line 1002,
in _send_single_request
response = transport.handle_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx\_transports\default.py", line 217, in handle_request
with map_httpcore_exceptions():
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 155, in __exit__
self.gen.throw(typ, value, traceback)
File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx\_transports\default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ConnectError: [WinError 10054] An existing connection was forcibly closed by the remote host
PS C:\Users\a\b\c\d\marketwatch>
Go to this page and try to login with the email and password
Then Go to this page and go check your email and password
https://customercenter.marketwatch.com/account?mod=mh_sidebar
Try replacing the os with the credentials in python
from marketwatch import MarketWatch
marketwatch = MarketWatch("Shmed@gmail.com", "password1234")
If there a error in auth
I personally use linux so i cannot test on windows http requests. It looks like that the ssl library and auth on windows is differents
@shmedd, I've just pushed a new version of the library and am currently conducting tests on Windows. Everything appears to be functioning correctly.
You can view the test results here: GitHub Actions Run
It's possible that the issue you're encountering is due to missing packages in your Python environment. Could you please generate a list of your installed packages? You can do this by running the following command:
bash
pip install marketwatch --upgrade
pip freeze > pip.txt
This will create a file named pip.txt in your current directory, containing a list of all installed Python packages. Please share this file so I can help troubleshoot the issue further.
pip.txt:
annotated-types==0.6.0
anyio==4.2.0
beautifulsoup4==4.12.3
certifi==2023.11.17
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
EasyProcess==1.1
entrypoint2==1.1
fastapi==0.109.0
h11==0.14.0
httpcore==1.0.2
httpx==0.26.0
idna==3.6
iniconfig==2.0.0
Jinja2==3.1.3
keyboard==0.13.5
markdown-it-py==3.0.0
marketwatch==0.2.2
MarkupSafe==2.1.4
mdurl==0.1.2
MouseInfo==0.1.3
mss==9.0.1
numpy==1.26.3
packaging==23.2
pandas==2.2.0
Pillow==9.5.0
pluggy==1.4.0
py==1.11.0
pyarrow==15.0.0
PyAutoGUI==0.9.54
pydantic==2.5.3
pydantic_core==2.14.6
PyGetWindow==0.0.9
Pygments==2.17.2
PyMsgBox==1.0.9
pyperclip==1.8.2
PyRect==0.2.0
pyscreenshot==3.1
PyScreeze==0.1.29
pytest==7.4.4
python-dateutil==2.8.2
pytweening==1.0.7
pytz==2023.3.post1
requests==2.31.0
rich==13.7.0
six==1.16.0
sniffio==1.3.0
soupsieve==2.5
starlette==0.35.1
typing_extensions==4.9.0
tzdata==2023.4
urllib3==2.1.0
uvicorn==0.27.0
Nothing looks wrong here in the pip package.
ConnectionResetError (WinError 10054): This error occurs when a TCP/IP connection is forcibly closed by the server or an intermediary (like a firewall). In your case, this happens during an SSL handshake, indicating a possible issue with the server accepting the connection or a network-level blockage.
Probable Causes:
The server at sso.accounts.dowjones.com forcibly closes the connection, possibly due to security settings, SSL/TLS version mismatches, or unrecognized client headers. Network-level issues such as firewalls or antivirus software blocking the connection. Issues with the Python environment or the httpx and ssl modules, though this is less likely given the nature of the error.
I cannot reproduce this issue in my windows and linux and automatic tests environments.
I trying to fix in this branch : https://github.com/antoinebou12/marketwatch/pull/142
Note: try to reinstall python3 on your windows machine from the windows store
I have merge the changes in new releases @shmedd. If that doesn't work please give me more information on how you install python or virtual env
Downloading the latest release solved all my issues. Thank you so much!
Downloading the latest release solved all my issues. Thank you so much!
If you need help in your projects please tell me or you need another feature.
Thanks you 😊
Every attempt to use the MarketWatch tools immediately runs into an error, starting with the log in step. I have made sure the email and password variables are correct, and are not linked to a google-account-profile.