爬虫類Scrapyフレームワークプロジェクトの実行時にエラーが発生しました.解決を求めます!
E:\JetBrains\PyCharm\mySpider>scrapy crawl itcast -o itcast.json
2018-03-26 14:50:23 [scrapy.utils.log] INFO: Scrapy 1.5.0 started (bot: mySpider)
2018-03-26 14:50:23 [scrapy.utils.log] INFO: Versions: lxml 4.2.1.0, libxml2 2.9.5, cssselect 1.0.3, parsel 1.4.0, w3lib
1.19.0, Twisted 17.9.0, Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)], pyOpenSSL 17.
5.0 (OpenSSL 1.1.0g 2 Nov 2017), cryptography 2.2.1, Platform Windows-10-10.0.16299-SP0
2018-03-26 14:50:23 [scrapy.crawler] INFO: Overridden settings: {'BOT_NAME': 'mySpider', 'FEED_FORMAT': 'json', 'FEED_UR
I': 'itcast.json', 'NEWSPIDER_MODULE': 'mySpider.spiders', 'SPIDER_MODULES': ['mySpider.spiders']}
2018-03-26 14:50:23 [scrapy.middleware] INFO: Enabled extensions:
['scrapy.extensions.corestats.CoreStats',
'scrapy.extensions.telnet.TelnetConsole',
'scrapy.extensions.feedexport.FeedExporter',
'scrapy.extensions.logstats.LogStats']
2018-03-26 14:50:23 [scrapy.middleware] INFO: Enabled downloader middlewares:
['scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware',
'scrapy.downloadermiddlewares.downloadtimeout.DownloadTimeoutMiddleware',
'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware',
'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware',
'scrapy.downloadermiddlewares.retry.RetryMiddleware',
'scrapy.downloadermiddlewares.redirect.MetaRefreshMiddleware',
'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware',
'scrapy.downloadermiddlewares.redirect.RedirectMiddleware',
'scrapy.downloadermiddlewares.cookies.CookiesMiddleware',
'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware',
'scrapy.downloadermiddlewares.stats.DownloaderStats']
2018-03-26 14:50:23 [scrapy.middleware] INFO: Enabled spider middlewares:
['scrapy.spidermiddlewares.httperror.HttpErrorMiddleware',
'scrapy.spidermiddlewares.offsite.OffsiteMiddleware',
'scrapy.spidermiddlewares.referer.RefererMiddleware',
'scrapy.spidermiddlewares.urllength.UrlLengthMiddleware',
'scrapy.spidermiddlewares.depth.DepthMiddleware']
2018-03-26 14:50:23 [scrapy.middleware] INFO: Enabled item pipelines:
[]
2018-03-26 14:50:23 [scrapy.core.engine] INFO: Spider opened
2018-03-26 14:50:23 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min
)
2018-03-26 14:50:23 [scrapy.extensions.telnet] DEBUG: Telnet console listening on 127.0.0.1:6023
2018-03-26 14:50:33[scrapy.downloadermiddlewares.retry]DEBUG:Retrying>(failed 1 times):Connection was refused by other side:10061:ターゲットコンピュータが積極的に拒否しているため接続できません.
2018-03-26 14:50:34[scrapy.downloadermiddlewares.retry]DEBUG:Retrying>(failed 2 times):Connection was refused by other side:10061:ターゲットコンピュータが積極的に拒否しているため接続できません.
2018-03-26 14:50:35 [scrapy.downloadermiddlewares.retry] DEBUG: Gave up retrying er.shtml>(failed 3 times):Connection was refused by other side:10061:ターゲットコンピュータが積極的に拒否したため、接続できません.
2018-03-26 14:50:35 [scrapy.core.scraper] ERROR: Error downloading : Con
nection was refused by other side:10061:ターゲットコンピュータが積極的に拒否したため、接続できません..
2018-03-26 14:50:35 [scrapy.core.engine] INFO: Closing spider (finished)
2018-03-26 14:50:35 [scrapy.statscollectors] INFO: Dumping Scrapy stats:
{'downloader/exception_count': 3,
'downloader/exception_type_count/twisted.internet.error.ConnectionRefusedError': 3,
'downloader/request_bytes': 699,
'downloader/request_count': 3,
'downloader/request_method_count/GET': 3,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2018, 3, 26, 6, 50, 35, 950498),
'log_count/DEBUG': 4,
'log_count/ERROR': 1,
'log_count/INFO': 7,
'retry/count': 2,
'retry/max_reached': 1,
'retry/reason_count/twisted.internet.error.ConnectionRefusedError': 2,
'scheduler/dequeued': 3,
'scheduler/dequeued/memory': 3,
'scheduler/enqueued': 3,
'scheduler/enqueued/memory': 3,
'start_time': datetime.datetime(2018, 3, 26, 6, 50, 23, 644724)}
2018-03-26 14:50:35 [scrapy.core.engine] INFO: Spider closed (finished)
爬虫類の白い新しい入門はScrapyの枠組みを学び始めて、これは私が登って知恵の放送者の公式サイトの情報の実例を伝えます
しかし、実行プログラムは、ターゲットコンピュータが積極的に拒否したため、接続できないと報告した.
今大神の解决を求めます!
ソース:
2018-03-26 14:50:23 [scrapy.utils.log] INFO: Scrapy 1.5.0 started (bot: mySpider)
2018-03-26 14:50:23 [scrapy.utils.log] INFO: Versions: lxml 4.2.1.0, libxml2 2.9.5, cssselect 1.0.3, parsel 1.4.0, w3lib
1.19.0, Twisted 17.9.0, Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)], pyOpenSSL 17.
5.0 (OpenSSL 1.1.0g 2 Nov 2017), cryptography 2.2.1, Platform Windows-10-10.0.16299-SP0
2018-03-26 14:50:23 [scrapy.crawler] INFO: Overridden settings: {'BOT_NAME': 'mySpider', 'FEED_FORMAT': 'json', 'FEED_UR
I': 'itcast.json', 'NEWSPIDER_MODULE': 'mySpider.spiders', 'SPIDER_MODULES': ['mySpider.spiders']}
2018-03-26 14:50:23 [scrapy.middleware] INFO: Enabled extensions:
['scrapy.extensions.corestats.CoreStats',
'scrapy.extensions.telnet.TelnetConsole',
'scrapy.extensions.feedexport.FeedExporter',
'scrapy.extensions.logstats.LogStats']
2018-03-26 14:50:23 [scrapy.middleware] INFO: Enabled downloader middlewares:
['scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware',
'scrapy.downloadermiddlewares.downloadtimeout.DownloadTimeoutMiddleware',
'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware',
'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware',
'scrapy.downloadermiddlewares.retry.RetryMiddleware',
'scrapy.downloadermiddlewares.redirect.MetaRefreshMiddleware',
'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware',
'scrapy.downloadermiddlewares.redirect.RedirectMiddleware',
'scrapy.downloadermiddlewares.cookies.CookiesMiddleware',
'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware',
'scrapy.downloadermiddlewares.stats.DownloaderStats']
2018-03-26 14:50:23 [scrapy.middleware] INFO: Enabled spider middlewares:
['scrapy.spidermiddlewares.httperror.HttpErrorMiddleware',
'scrapy.spidermiddlewares.offsite.OffsiteMiddleware',
'scrapy.spidermiddlewares.referer.RefererMiddleware',
'scrapy.spidermiddlewares.urllength.UrlLengthMiddleware',
'scrapy.spidermiddlewares.depth.DepthMiddleware']
2018-03-26 14:50:23 [scrapy.middleware] INFO: Enabled item pipelines:
[]
2018-03-26 14:50:23 [scrapy.core.engine] INFO: Spider opened
2018-03-26 14:50:23 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min
)
2018-03-26 14:50:23 [scrapy.extensions.telnet] DEBUG: Telnet console listening on 127.0.0.1:6023
2018-03-26 14:50:33[scrapy.downloadermiddlewares.retry]DEBUG:Retrying>(failed 1 times):Connection was refused by other side:10061:ターゲットコンピュータが積極的に拒否しているため接続できません.
2018-03-26 14:50:34[scrapy.downloadermiddlewares.retry]DEBUG:Retrying>(failed 2 times):Connection was refused by other side:10061:ターゲットコンピュータが積極的に拒否しているため接続できません.
2018-03-26 14:50:35 [scrapy.downloadermiddlewares.retry] DEBUG: Gave up retrying er.shtml>(failed 3 times):Connection was refused by other side:10061:ターゲットコンピュータが積極的に拒否したため、接続できません.
2018-03-26 14:50:35 [scrapy.core.scraper] ERROR: Error downloading : Con
nection was refused by other side:10061:ターゲットコンピュータが積極的に拒否したため、接続できません..
2018-03-26 14:50:35 [scrapy.core.engine] INFO: Closing spider (finished)
2018-03-26 14:50:35 [scrapy.statscollectors] INFO: Dumping Scrapy stats:
{'downloader/exception_count': 3,
'downloader/exception_type_count/twisted.internet.error.ConnectionRefusedError': 3,
'downloader/request_bytes': 699,
'downloader/request_count': 3,
'downloader/request_method_count/GET': 3,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2018, 3, 26, 6, 50, 35, 950498),
'log_count/DEBUG': 4,
'log_count/ERROR': 1,
'log_count/INFO': 7,
'retry/count': 2,
'retry/max_reached': 1,
'retry/reason_count/twisted.internet.error.ConnectionRefusedError': 2,
'scheduler/dequeued': 3,
'scheduler/dequeued/memory': 3,
'scheduler/enqueued': 3,
'scheduler/enqueued/memory': 3,
'start_time': datetime.datetime(2018, 3, 26, 6, 50, 23, 644724)}
2018-03-26 14:50:35 [scrapy.core.engine] INFO: Spider closed (finished)
爬虫類の白い新しい入門はScrapyの枠組みを学び始めて、これは私が登って知恵の放送者の公式サイトの情報の実例を伝えます
しかし、実行プログラムは、ターゲットコンピュータが積極的に拒否したため、接続できないと報告した.
今大神の解决を求めます!
ソース:
import scrapy
from mySpider.items import MyspiderItem
class itcastSpider(scrapy.Spider):
#
name = "itcast"
#
allowed_domains = ["itcast.cn"]
#
start_urls = ["http://www.itcast.cn/channel/teacher.shtml"]
def parse(self, response):
note_list = response.xpath("//div[@class='li_txt']")
items = []
for list in note_list:
# item
item = MyspiderItem()
#.extract() xpath Unicode
te_name = list.xpath("./h3/text()").extract()
te_title = list.xpath("./h4/text()").extract()
te_info = list.xpath("./p/text()").extract()
#xpath [0]
# print(te_name[0])
# print(te_title[0])
# print(te_info[0])
# item
item['te_name'] = te_name[0]
item['te_title'] = te_title[0]
item['te_info'] = te_info[0]
items.append(item)
return items