Coder Social home page Coder Social logo

Request for image about grequests HOT 2 CLOSED

pasa13142 avatar pasa13142 commented on July 17, 2024
Request for image

from grequests.

Comments (2)

spyoungtech avatar spyoungtech commented on July 17, 2024

I'm not sure I can reproduce this problem. If you get None back in your results, it's usually because the request failed for some reason. You can add an exception handler to dig deeper into that.

def my_ex_handler(req, ex):
    print('request failed', req, ex)
# ...
for resp in grequests.map(reqs, exception_handler=my_ex_handler):
    print('response', resp)

But the following code should demonstrate that you can retrieve images using grequests:

import grequests

image_types = ['jpeg', 'png', 'svg']
urls = [f'https://httpbin.org/image/{it}' for it in image_types]
reqs = [grequests.get(url) for url in urls]

for resp in grequests.map(reqs):
    print(resp, len(resp.content))
    # or do whatever with ``resp.content``

And should get an output something like:

<Response [200]> 35588
<Response [200]> 8090
<Response [200]> 8984

from grequests.

pasa13142 avatar pasa13142 commented on July 17, 2024

Thank you! I got:

maximum recursion depth exceeded while calling a Python object
error with your handler and set it to 5000 and it works now.

import sys
sys.setrecursionlimit(5000)

Thanks!

from grequests.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.