Cafemmo Club
← Quay lại danh sách

[Python] - Có thể dùng multithreading với Requests hay không?

DVince01/03/20182918 lượt xem19 bình luận

Em chào mọi người,

Như title ạ. Mọi người cho em hỏi đã ai sử dụng Requests để crawl data từ web chưa ạ? Và có dùng multithreading được không? Vì em thử thì thấy nó không khác gì so với single threading cả. Và đọc trên document của Requests thì nó bảo như này: [QUOTE] Blocking Or Non-Blocking?

With the default Transport Adapter in place, Requests does not provide any kind of non-blocking IO. The Response.content property will block until the entire response has been downloaded. If you require more granularity, the streaming features of the library (see Streaming Requests) allow you to retrieve smaller quantities of the response at a time. However, these calls will still block.

If you are concerned about the use of blocking IO, there are lots of projects out there that combine Requests with one of Python's asynchronicity frameworks. Two excellent examples are [URL='https://github.com/kennethreitz/grequests']grequests[/URL] and requests-futures. [/QUOTE] Mọi người cho em xin ý kiến thảo luận cách crawl data bằng requests với multithreading hoặc cách khác hiệu quả hơn với ạ. Em cảm ơn.

Bình luận

Đang tải...

Đang kiểm tra đăng nhập...