Use requests for python2.7.13 scarping error

# request version
2.14.2
# os information
Linux programmer 4.8.0-58-generic #63~16.04.1-Ubuntu SMP Mon Jun 26 18:08:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
# code

```python
def get_html(url):
    headers = {'User-Agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'}
    request = requests.get(url=url,headers=headers) #发送get请求
    response = request.content #获取网页内容
    return response
def get_img_html(html):
    soup = BeautifulSoup(html,'lxml') #解析网页
    all_a = soup.find_all('a',class_ = 'list-group-item') #找到a标签
    for i in all_a:
        img_html = get_html(i['href']) #获取超链接的网页内容
        print img_html #网页源码
def get_img(html):
    soup = etree.HTML(html) #初始化源码
    items = soup.xpath('//div[@class="artile_des"]') #找这个盒子下面的内容
    for item in items:
        imgurl_list = item.xpath('table/tbody/tr/td/a/img/@onerror') #选取属性
        start_save_img(imgurl_list)
def save_img(img_url):
    img_url = img_url.split('=')[-1][1:-2].replace('jp','jpg') #分割
    print u"正在下载" + 'http:' + img_url
    img_content = requests.get('http:' + img_url).content
    with open('doutu/%s' % img_url.split('/')[-1],'wb') as f:
        f.write(img_content)
def start_save_img(imgurl_list):
    for i in imgurl_list:
        print i
        th = threading.Thread(target=save_img,args=(i,))
        th.start()
def main():
    start_url = 'https://www.doutula.com/article/list/?page='
    for i in range(1,10):
        start_html = get_html(start_url.format(i))
        get_img_html(start_html)
if __name__ == '__main__':
    main()
```

# Error

```
/home/kongnian/anaconda2/bin/python /home/kongnian/PycharmProjects/Scraping/DouTuScraping.py
Traceback (most recent call last):
  File "/home/kongnian/PycharmProjects/Scraping/DouTuScraping.py", line 52, in <module>
    main()
  File "/home/kongnian/PycharmProjects/Scraping/DouTuScraping.py", line 48, in main
    start_html = get_html(start_url.format(i))
  File "/home/kongnian/PycharmProjects/Scraping/DouTuScraping.py", line 10, in get_html
    request = requests.get(url=url,headers=headers) #发送get请求
  File "/home/kongnian/anaconda2/lib/python2.7/site-packages/requests/api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "/home/kongnian/anaconda2/lib/python2.7/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/kongnian/anaconda2/lib/python2.7/site-packages/requests/sessions.py", line 518, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/kongnian/anaconda2/lib/python2.7/site-packages/requests/sessions.py", line 639, in send
    r = adapter.send(request, **kwargs)
  File "/home/kongnian/anaconda2/lib/python2.7/site-packages/requests/adapters.py", line 512, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: ("bad handshake: SysCallError(104, 'ECONNRESET')",)
```

In this context it seems like the connection is being closed as we send more data. Rude, but not entirely unusual. Does it happen deterministically or only occasionally?

Yesterday normal, today an error occurred.

If this is intermittent then I think you just have to tolerate this as being "network weather": the kind of error that will occasionally occur in long-running networked programs. If you hit this condition, I recommend retrying.

OK,thanks