jundymek / free-proxy

Free proxy scraper written in python. It is pypi library - free to use.
MIT License
248 stars 46 forks source link

AttributeError: __enter__ #6

Closed mebibou closed 2 years ago

mebibou commented 4 years ago

When trying to run this on python 3.7, I get the following error

self = <fp.fp.FreeProxy object at 0x7f11da8c2490>
proxies = {'http': 'http://104.41.54.53:3128'}

    def check_if_proxy_is_working(self, proxies):
>       with requests.get('http://www.google.com', proxies=proxies, timeout=self.timeout, stream=True) as r:
E       AttributeError: __enter__
jundymek commented 4 years ago

I can't reproduce this error. Below is my virtualenv config and Python 3.7.7 output: Screenshot 2020-09-12 at 19 44 20 Screenshot 2020-09-12 at 19 44 33

Is there anyone else with the same problem?

AyushMukherjee commented 3 years ago

I am facing the same issue with Python 3.8. The output:

> from fp.fp import FreeProxy
> proxy = FreeProxy(rand=True, timeout=1)
> proxy
<fp.fp.FreeProxy object at 0x7fc0004c82b0>
> my_proxy = proxy.get()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/fp/fp.py", line 49, in get
    if self.check_if_proxy_is_working(proxies):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/fp/fp.py", line 63, in check_if_proxy_is_working
    with requests.get('http://www.google.com', proxies=proxies, timeout=self.timeout, stream=True) as r:
AttributeError: __enter__

My environment:

Package                       Version   
----------------------------- ----------
absl-py                       0.11.0    
aiohttp                       3.7.3     
alabaster                     0.7.12    
antlr4-python3-runtime        4.9.1     
appdirs                       1.4.4     
arrow                         0.17.0    
astroid                       2.4.2     
astunparse                    1.6.3     
async-timeout                 3.0.1     
attrs                         20.3.0    
Babel                         2.9.0     
beautifulsoup4                4.9.3     
bibtexparser                  1.2.0     
black                         20.8b1    
blessings                     1.7       
bpython                       0.21      
CacheControl                  0.12.6    
cachetools                    4.2.1     
cachy                         0.3.0     
Cerberus                      1.3.2     
certifi                       2020.12.5 
cffi                          1.14.4    
chardet                       3.0.4     
cleo                          0.7.6     
click                         7.1.2     
clikit                        0.4.3     
crashtest                     0.3.1     
cryptography                  3.3.1     
cs50                          6.0.2     
curtsies                      0.3.5     
cwcwidth                      0.1.1     
cycler                        0.10.0    
dephell                       0.8.3     
dephell-archive               0.1.7     
dephell-argparse              0.1.3     
dephell-changelogs            0.0.1     
dephell-discover              0.2.10    
dephell-licenses              0.1.7     
dephell-links                 0.1.5     
dephell-markers               1.0.3     
dephell-pythons               0.1.15    
dephell-setuptools            0.2.4     
dephell-shells                0.1.5     
dephell-specifier             0.2.2     
dephell-venvs                 0.1.18    
dephell-versioning            0.1.2     
discord                       1.0.1     
discord.py                    1.6.0     
distlib                       0.3.1     
docopt                        0.6.2     
docutils                      0.16      
fake-useragent                0.1.11    
filelock                      3.0.12    
Flask                         1.1.2     
fp                            0.2       
free-proxy                    1.0.2     
funcsigs                      1.0.2     
future                        0.18.2    
gast                          0.3.3     
glfw                          2.0.0     
google-auth                   1.24.0    
google-auth-oauthlib          0.4.2     
google-pasta                  0.2.0     
greenlet                      1.0.0     
grpcio                        1.35.0    
h5py                          2.10.0    
html5lib                      1.1       
idna                          3.1       
imagesize                     1.2.0     
isort                         5.7.0     
itsdangerous                  1.1.0     
jedi                          0.17.2    
jeepney                       0.6.0     
Jinja2                        2.11.3    
joblib                        1.0.0     
jsonschema                    3.2.0     
Keras-Preprocessing           1.1.2     
keyring                       20.0.1    
kiwisolver                    1.3.1     
latexcodec                    2.0.1     
lazy-object-proxy             1.4.3     
lockfile                      0.12.2    
lxml                          4.6.2     
m2r                           0.2.1     
Markdown                      3.3.3     
MarkupSafe                    1.1.1     
matplotlib                    3.3.3     
mccabe                        0.6.1     
mistune                       0.8.4     
msgpack                       1.0.2     
multidict                     5.1.0     
mypy-extensions               0.4.3     
nltk                          3.5       
numpy                         1.19.5    
oauthlib                      3.1.0     
opt-einsum                    3.3.0     
packaging                     20.9      
parso                         0.7.1     
pastel                        0.2.1     
pathspec                      0.8.1     
pexpect                       4.8.0     
Pillow                        8.1.0     
pip                           19.3.1    
pipreqs-amasad                0.4.10    
pkginfo                       1.7.0     
pluggy                        0.13.1    
poetry                        1.0.5     
poetry-core                   1.0.0     
prompt-toolkit                3.0.14    
protobuf                      3.14.0    
ptpython                      3.0.13    
ptyprocess                    0.7.0     
pyasn1                        0.4.8     
pyasn1-modules                0.2.8     
pybtex                        0.24.0    
pybtex-apa-style              1.3       
pycodestyle                   2.6.0     
pycparser                     2.20      
pyflakes                      2.2.0     
pygame                        2.0.1     
Pygments                      2.7.4     
pylev                         1.3.0     
pylint                        2.6.0     
PyOpenGL                      3.1.5     
pyOpenSSL                     20.0.1    
pyparsing                     2.4.7     
pyquil                        1.9.0     
pyrsistent                    0.14.11   
PySocks                       1.7.1     
python-dateutil               2.8.1     
python-dotenv                 0.15.0    
python-jsonrpc-server         0.4.0     
python-language-server        0.36.2    
pytz                          2021.1    
pyxdg                         0.27      
pyxel                         1.0.1     
PyYAML                        5.4.1     
referenceqvm                  0.3       
regex                         2020.11.13
replit                        2.0.0     
requests                      2.15.1    
requests-oauthlib             1.3.0     
requests-toolbelt             0.8.0     
rope                          0.18.0    
rsa                           4.7       
ruamel.yaml                   0.16.12   
ruamel.yaml.clib              0.2.2     
scholarly                     1.0.6     
scipy                         1.4.1     
SecretStorage                 3.3.0     
selenium                      3.141.0   
setuptools                    49.2.1    
shellingham                   1.3.2     
six                           1.15.0    
snowballstemmer               2.1.0     
sounddevice                   0.4.1     
soupsieve                     2.1       
Sphinx                        3.4.3     
sphinx-rtd-theme              0.5.1     
sphinxcontrib-applehelp       1.0.2     
sphinxcontrib-devhelp         1.0.2     
sphinxcontrib-htmlhelp        1.0.3     
sphinxcontrib-jsmath          1.0.1     
sphinxcontrib-qthelp          1.0.3     
sphinxcontrib-serializinghtml 1.1.4     
SQLAlchemy                    1.3.22    
sqlparse                      0.4.1     
stem                          1.8.0     
tensorboard                   2.2.2     
tensorboard-plugin-wit        1.8.0     
tensorflow-cpu                2.2.0     
tensorflow-estimator          2.2.0     
termcolor                     1.1.0     
toml                          0.10.2    
tomlkit                       0.5.11    
tqdm                          4.56.0    
typed-ast                     1.4.2     
typing-extensions             3.7.4.3   
ujson                         4.0.2     
urllib3                       1.26.3    
virtualenv                    20.4.0    
wcwidth                       0.2.5     
webencodings                  0.5.1     
Werkzeug                      1.0.1     
wheel                         0.36.2    
wrapt                         1.12.1    
yapf                          0.30.0    
yarg                          0.1.9     
yarl                          1.6.3     
yaspin                        1.3.0     
AyushMukherjee commented 3 years ago

It worked with the updated requests module.