How to handle IncompleteRead: in python

后端 未结 8 1634
面向向阳花
面向向阳花 2020-12-05 10:12

I am trying to fetch some data from a website. However it returns me incomplete read. The data I am trying to get is a huge set of nested links. I did some rese

相关标签:
8条回答
  • 2020-12-05 10:48

    I found that my virus detector/firewall was causing this problem. "Online Shield" part of AVG.

    0 讨论(0)
  • 2020-12-05 10:48

    python3 FYI

    from urllib import request
    import http.client
    import os
    url = 'http://shop.o2.co.uk/mobile_phones/Pay_Monthly/smartphone/all_brand'
    try:    
        response = request.urlopen(url)                                       
        file = response.read()  
    except http.client.IncompleteRead as e:
        file = e.partial
    except Exception as result:
        print("Unkonw error" + str(result))
        return
    
    #   save  file 
        with open(file_path, 'wb') as f:
             print("save -> %s " % file_path)
             f.write(file)
    
    0 讨论(0)
提交回复
热议问题