2

I want to scrape this link using scrapy. The link in browser is referring to another http request. Accessing this referred call in browser directly returns: {"message": "Invalid or expired token"}. Following the answer mentioned here I did:

scrapy shell
headers= {'X-JadoPado-API-Token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHAiOiJqYWRvcGFkby5jb20iLCJ1c2VySWQiOm51bGwsImV4cCI6MTQ5NDMzMjE0OSwia2lkIjoiYWQxNWY3N2I0NzlmNDIxOTk0OGI5Y2U3MzMyOTQ2MzciLCJkZXZpY2UiOiI3YTc4YzM4Mi01N2VhLTQ3YjItODBiNi1lZTUzYjQ4MzhjNjAifQ.DWrdaIsFCTSAvfk2DEUrdxeloCSNArEk1zDncKlFz0M'}
req = Request("https://jadopado.com/en-sa/mobile-phones/c/4298?filter=&page=2&sorting=-launchedAt", headers=headers)
fetch(req)

I also tried doing the same thing setting all headers request headers

 headers = 
     {'Accept':'application/json',
    'Accept-Encoding':'gzip, deflate, br',
    'Accept-Language':'en-US,en;q=0.5',
    'Cache-Control':'no-cache',
    'Connection':'keep-alive',
    'Host':'api.jadopado.com',
    'Origin':'https://jadopado.com',
    'Referer':'https://jadopado.com/en-sa/mobile-phones/c/4298?filter=&page=2&sorting=-launchedAt',
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0',
    'X-JadoPado-API-Token':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHAiOiJqYWRvcGFkby5jb20iLCJ1c2VySWQiOm51bGwsImV4cCI6MTQ5NDMzMjE0OSwia2lkIjoiYWQxNWY3N2I0NzlmNDIxOTk0OGI5Y2U3MzMyOTQ2MzciLCJkZXZpY2UiOiI3YTc4YzM4Mi01N2VhLTQ3YjItODBiNi1lZTUzYjQ4MzhjNjAifQ.DWrdaIsFCTSAvfk2DEUrdxeloCSNArEk1zDncKlFz0M',
    'X-JadoPado-Currency':'SAR',
    'X-JadoPado-Locale':'en',
    }

Even this did not work. Am I missing anything or is there a better way to scrape link with scrapy?

Community
  • 1
  • 1
Javed
  • 5,904
  • 4
  • 46
  • 71

1 Answers1

2

You might be using correct headers but not the correct URL.

See Request URL

enter image description here

Try this code.

headers = {
    'Origin': 'https://jadopado.com',
    'Accept-Encoding': 'gzip, deflate, sdch, br',
    'Accept-Language': 'en-US,en;q=0.8',
    'X-JadoPado-Locale': 'en',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36',
    'X-JadoPado-Currency': 'SAR',
    'Accept': 'application/json',
    'Cache-Control': 'no-cache',
    'DNT': '1',
    'Connection': 'keep-alive',
    'Referer': 'https://jadopado.com/en-sa/mobile-phones/c/4298?filter=&page=1&sorting=-launchedAt',
    'X-JadoPado-API-Token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHAiOiJqYWRvcGFkby5jb20iLCJ1c2VySWQiOm51bGwsImV4cCI6MTQ5NDMzNTAzOSwia2lkIjoiYWMxOWM0YTFlY2FhNDA2MGE5ZjEwYjE1ZGQ3ZmUzZjMiLCJkZXZpY2UiOiJhNDQ4YWFmOS0zMDI0LTQ1NGQtOTg0MC0zYzMxZGI1YzcwMDcifQ.2m2VQ13owO0kLy8shcLuzuAPE8iNEsPEA0p4x640K8o',
}



yield Request('https://api.jadopado.com/v1/categories/?parentId=4298&page=1&recordsPerPage=500&showFee=true', headers=headers)
Umair Ayub
  • 19,358
  • 14
  • 72
  • 146