使用scrapy框架,抓取网址
:https://www.glutnn.cn/list.aspx?classid=110101
上的标题,请给出爬虫文件 itcast.py 的代码。
import scrapy
class ItcastSpider(scrapy.Spider):
name = "itcast"
allowed_domains = ["www.glutnn.cn"]
start_urls = ["https://www.glutnn.cn/list.aspx?classid=110101"]
def parse(self, response):
node_title = response.xpath("//td[@class='td_list']")
for node in node_title:
title = node.xpath("./a/text()")
print(title)