dimanche 4 août 2019

How can i send POST request through FormRequest With Parameters

I am trying to send ajax POST Request Through FormRequest in scrapy.

I already send ajax request through request.Session and i get my desired result but i want to do it in scrapy how can i do that please guide me.

ajax post request through request.Session code

first_iteration = True

data = {'video_id': self.youtube_id,
       'session_token': session_token}

params = {'action_load_comments': 1,
          'order_by_time': True,
          'filter': self.youtube_id}

if first_iteration:
    params['order_menu'] = True
else:
    data['page_token'] = page_token   

def ajax_request(self, url, params, data, retries=10, sleep=20):
    session=request.Session()
    for _ in range(retries):
        response = session(url, params=params, data=data)
        if response.status_code == 200:
            response_dict = json.loads(response.text)
            return response_dict.get('page_token', None), response_dict['html_content']
        else:
            time.sleep(sleep)

want to send ajax POST request through FormRequest scrapy

i am new to use scrapy anyone how can help me and write down that request for me i am very thankful.




Aucun commentaire:

Enregistrer un commentaire