import scrapy
from myproject.items import MyItem
class MySpider(scrapy.Spider):
name = ’example.com’ allowed_domains = [’example.com’] start_urls = [
        ’http://www.example.com/1.html’,
        ’http://www.example.com/2.html’,
        ’http://www.example.com/3.html’,
]
def parse(self, response):   for h3 in response.xpath(’//h3’).extract():     yield MyItem(title=h3)
  
for url in response.xpath(’//a/@href’).extract():
    yield scrapy.Request(url, callback=self.parse)

 

相关文章:

  • 2021-11-23
  • 2021-09-19
  • 2021-10-12
  • 2021-12-06
  • 2022-12-23
  • 2021-07-08
  • 2021-07-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案