I am using Scrapy to scrap a web page. That page is little bit slow. So, first it shows a loading gif icon and then loads the whole page. When I am using Scrapy, it is just taking the loading gif icon. I want to wait for few seconds until the page loads completely.
Language :- Python 2
Code :-
import scrapy
import time
class QuotesSpider(scrapy.Spider):
name = "quotes"
download_delay = 15.0
def start_requests(self):
urls = [
'exaple.com'
]
time.sleep(1)
for url in urls:
yield scrapy.Request(url=url, callback=self.parse)
def parse(self, response):
page = response.url.split("/")[-2]
filename = 'quotes-%s.html' % page
with open(filename, 'wb') as f:
f.write(response.body)
self.log('Saved file %s' % filename)
example.com
is the web page. Whenever I open the output HTML file, it shows me the loading icon only. What is the recommended way to achieve this ?
I am trying to use the time.sleep(1)
, but output is same.
I am following this tutorial :- https://doc.scrapy.org/en/latest/intro/tutorial.html