I try to extract data from https://www.marinetraffic.com/en/ais/details/ships/imo:9829069/ using the following scrapy's spider and then I save the response to file.html.
# -*- coding: utf-8 -*-
import scrapy
from fake_useragent import UserAgent
class MarinetrafficSpider(scrapy.Spider):
name = 'marinetraffic'
allowed_domains = ['marinetraffic.com']
ua = UserAgent()
ua.update()
def start_requests(self):
urls = [
'https://www.marinetraffic.com/en/ais/details/ships/imo:9829069/'
]
headers= {'User-Agent': self.ua['google chrome'] }
for url in urls:
yield scrapy.Request(url, callback=self.parse, headers=headers)
def parse(self, response):
with open('file.html', 'wb') as f:
f.write(response.body)
self.log('Saved file')
But I don't take the expected response. The returned response is in file.html
Please check the debug results.
What modifications do I need to do on the above code so that the returned response be the same as the response I take from the browser?
I will apprisiate your notings.