【发布时间】:2018-08-05 23:09:53
【问题描述】:
我正在尝试从一个网站抓取几个页面。为此,我有不同的起始 URL 和爬取下一页的方法。 问题是蜘蛛不会scrape 项目并且似乎没有爬取指定的页面。我没有结果。 你有什么办法解决这个问题吗?
这是代码
class ListeCourse_level1(scrapy.Spider):
name = nom_robot
allowed_domains = domaine
start_urls = url_lister()
print(start_urls)
print('-----------------------------')
def parse(self, response):
selector = Selector(response)
for unElement in response.xpath('//*[@id="td-outer-wrap"]/div[3]/div/div/div[1]/div/div[2]/div[3]/table/tbody/tr'):
loader = ItemLoader(JustrunlahItem(), selector=unElement)
loader.add_xpath('eve_nom_evenement', './/td[2]/div/div[1]/div/a/text()')
loader.add_xpath('eve_date_deb', './/td[1]/div/text()')
loader.default_input_processor = MapCompose(string)
loader.default_output_processor = Join()
yield loader.load_item()
shell 窗口的提取
--------------------------------------------------
SCRAPING DES ELEMENTS EVENTS
--------------------------------------------------
2018-02-26 14:13:21 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://www.justrunlah.com/running-events-calendar-malaysia/page/9/> (referer: None)
--------------------------------------------------
SCRAPING DES ELEMENTS EVENTS
--------------------------------------------------
--------------------------------------------------
SCRAPING DES ELEMENTS EVENTS
--------------------------------------------------
2018-02-26 14:13:21 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://www.justrunlah.com/running-events-calendar-malaysia/page/7/> (referer: None)
--------------------------------------------------
SCRAPING DES ELEMENTS EVENTS
--------------------------------------------------
--------------------------------------------------
SCRAPING DES ELEMENTS EVENTS
--------------------------------------------------
2018-02-26 14:13:21 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://www.justrunlah.com/running-events-calendar-malaysia/page/2/> (referer: None)
--------------------------------------------------
SCRAPING DES ELEMENTS EVENTS
--------------------------------------------------
2018-02-26 14:13:22 [scrapy.core.engine] INFO: Closing spider (finished)
2018-02-26 14:13:22 [scrapy.statscollectors] INFO: Dumping Scrapy stats:
{'downloader/request_bytes': 6899,
'downloader/request_count': 21,
'downloader/request_method_count/GET': 21,
'downloader/response_bytes': 380251,
'downloader/response_count': 21,
'downloader/response_status_count/200': 12,
'downloader/response_status_count/301': 9,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2018, 2, 26, 13, 13, 22, 63002),
'log_count/DEBUG': 22,
'log_count/INFO': 7,
'response_received_count': 12,
'scheduler/dequeued': 20,
'scheduler/dequeued/memory': 20,
'scheduler/enqueued': 20,
'scheduler/enqueued/memory': 20,
'start_time': datetime.datetime(2018, 2, 26, 13, 13, 17, 308549)}
2018-02-26 14:13:22 [scrapy.core.engine] INFO: Spider closed (finished)
(C:\Users\guichet-v\AppData\Local\Continuum\anaconda3) C:\Users\guichet-v\Documents\CHALLENGE\02_TRAVAIL\ETAPE_1_WebToSGBD\SCRIPT\justrunlah>
【问题讨论】:
标签: python web-scraping scrapy