'Scrapy: 403 TTP status code is not handled or not allowed

I have followed a few websites to add the headers on my request to get the results, but it is not working at all. This is my code: I have no idea how this should work.. someone help me plz

class JobsSpider(scrapy.Spider):
    name = "ziprecruiter"
    #user_agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1"
    #start_urls = [f'https://www.ziprecruiter.com/jobs-search?search=Port&location=Vancouver,%20CA']



    #user_agent =  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36'
    #allowed_domains = ["ziprecruiter.com"]
    #start_urls = ['https://www.ziprecruiter.com/']

    def __init__(self, job='Porter',location='Vancouver,%20',country="CA", **kwargs):
        self.name="ziprecruiter"
        self.allowed_domains = ["ziprecruiter.com"]
        self.combine = location+country
        self.user_agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1"
        self.job = job
        self.start_urls = ['https://www.ziprecruiter.com/']
        #self.header={'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0'}
        #self.user_agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1"
        #self.start_urls = [f'https://www.ziprecruiter.com/jobs-search?search={category}&location={self.combine}']  # py36

        super().__init__(**kwargs)  # python3
    #.xpath('//div[@class="job_title_raw"]').extract()/a[@class="job_link"]/h2[@class="title"]

    def parse(self, response):
        response.request.headers.get("referer")
        request = scrapy.FormRequest.from_response(
            response,
            formname='search_form job_search_form',
            formdata={'search':'Porter','location':''},

        )
        print(request.body)
        yield request```


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source