Advertisement
dereksir

Untitled

Aug 14th, 2023 (edited)
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. import scrapy
  2. from scrapy_splash import SplashRequest
  3.  
  4. class SplashSpider(scrapy.Spider):
  5.     name = 'splash_spider'
  6.     start_urls = ['https://angular.io/docs']
  7.  
  8.     def start_requests(self):
  9.         # Generate SplashRequests to the specified start URLs with a 2-second delay.
  10.         for url in self.start_urls:
  11.             yield SplashRequest(url, self.parse, args={'wait': 2})
  12.  
  13.     def parse(self, response):
  14.         # Extract the title from the response HTML using a CSS selector.
  15.         title = response.css('title::text').get()
  16.         yield {'title': title}
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement