As shown in figure
# - * - coding: utf-8 - * -
The import scrapy
The class TiebaPaSpider (scrapy. Spiders) :
Name='tieba_pa'
Allowed_domains=[' tieba.com ']
Start_urls=[' https://tieba.baidu.com/f?ie=utf-8&kw=lol ']
Def parse (self, response) :
Tieba_data=https://bbs.csdn.net/topics/response.xpath ("//ul [contains (@ id, 'thread_list)]/li ")
For tieba_l tieba_data in:
Title=tieba_l. Xpath (".//a [contains (@ class, 'j_th_tit)]/text () ")
The content=tieba_l. Xpath (".//div [contains (@ class, 'threadlist_abs threadlist_abs_onlyline')]/text () ")
Time=tieba_l. Xpath (".//span [@ title='reply last time']/text () ")
Print ("="* 20)
Print (title [0])
Print (content [0])
Print (time [0])
Print ("="* 20)
# tieba_data=https://bbs.csdn.net/topics/response.body
# print (tieba_data)