- Python 3.6.2
- CebtOS6.9
>>>s = requests.Session() >>>headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3)' 'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36','Accept': '*/*'} >>>s.get('http://Aサイト/aaa/xxx/ccc/aaa.jpg',headers=headers)
>>>s = requests.Session() >>>headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3)' 'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36','Accept': '*/*'} >>>s.get('http://Bサイト/aaa/xxx/ccc/aaa.jpg',headers=headers)
上記のようなpythonのインタプリタを使用してテストとしてサイトの画像を取得しようとしています。
が、
Aサイトでは下記のようなエラー
requests.exceptions.ConnectionError: HTTPConnectionPool(host='Aサイト', port=80): Max retries exceeded with url: /photo/20171218/20171218-OHT1I50155-T.jpg (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fea0d5f3da0>: Failed to establish a new connection: [Errno -2] Name or service not known',))
Bサイトでは
<Response [200]>
サイトによって成功したり失敗したりしています
これはAサイトでは何かしら画像を取得できないような仕組みが導入されているのでしょうか??
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。