LoginSignup
2
2

More than 3 years have passed since last update.

pythonのスクレイピング(requests)でエラーが出た時

Posted at

[Errno 11001]について

社内でpythonを使ってスクレイピングしようとしたとき、[Errno 11001]が出た。

プロキシ指定を行うと解決。

import requests
from bs4 import BeautifulSoup

proxies = {
'http': 'http://123.45.678.000:0000',
'https': 'http://123.45.678.000:0000',
}

url = 'https://ja.wikipedia.org/wiki/Python'
res = requests.get(url, verify=False, proxies=proxies)
soup = BeautifulSoup(res.text)

soup
<!DOCTYPE html>
<html class="client-nojs" dir="ltr" lang="ja">
<head>
<meta charset="utf-8"/>
<title>Python - Wikipedia</title>
<script>document.documentElement.className="client-js";RLCONF={"wgBreakFrames":!1,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"ja","wgMonthNames":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgMonthNamesShort":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgRequestId":"XhwEyQpAICIAABeLnhMAAADL","wgCSPNonce":!1,"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":!1,"wgNamespaceNumber":0,"wgPageName":"Python","wgTitle":"Python","wgCurRevisionId":75653560,"wgRevisionId":75653560,"wgArticleId":993,"wgIsArticle":!0,"wgIsRedirect":!1,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["無効な出典が含まれている記事/2018年","オブジェクト指向言語","スクリプト言語","オープンソースソフトウェア","Python","基本情報技術者試験"],"wgPageContentLanguage":"ja","wgPageContentModel":

・・・
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2