import cloudscraper
import requests
scraper = cloudscraper.create_scraper() # returns a CloudScraper instance
# Or: scraper = cloudscraper.CloudScraper() # CloudScraper inherits from requests.Session
print (scraper.get("https://www.youtube.com/").text )
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-459-1f19dc044105> in <module>
2 import requests
3
----> 4 scraper = cloudscraper.create_scraper() # returns a CloudScraper instance
5 # Or: scraper = cloudscraper.CloudScraper() # CloudScraper inherits from requests.Session
6 print (scraper.get("https://www.youtube.com/").text )
~/.local/lib/python3.6/site-packages/cloudscraper/__init__.py in create_scraper(cls, sess, **kwargs)
315 Convenience function for creating a ready-to-go CloudScraper object.
316
--> 317 scraper = cls(**kwargs)
318
319 if sess:
~/.local/lib/python3.6/site-packages/cloudscraper/__init__.py in __init__(self, *args, **kwargs)
169 server_hostname=self.server_hostname,
170 source_address=self.source_address,
--> 171 ssl_context=self.ssl_context
172 )
173 )
~/.local/lib/python3.6/site-packages/cloudscraper/__init__.py in __init__(self, *args, **kwargs)
75 self.ssl_context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
76
---> 77 self.ssl_context.orig_wrap_socket = self.ssl_context.wrap_socket
78 self.ssl_context.wrap_socket = self.wrap_socket
79
AttributeError: 'SSLContext' object has no attribute 'orig_wrap_socket'
The code was run according to the documentation on https://pypi.org/project/cloudscraper/ and I cant find relevant supporting information on how to solve this error message.
My scripts is working well until the latest version 1.2.60
release 12 days ago. Maybe is the problem with the old library ssl.py
in python3.6
.
Here are my temporally solution:
1.2.58
: pip3 install cloudscraper==1.2.58
3.7+
, tested working with python 3.7