本文整理匯總了Python中scrapy.FormRequest.headers['X-Requested-With']方法的典型用法代碼示例。如果您正苦於以下問題:Python FormRequest.headers['X-Requested-With']方法的具體用法?Python FormRequest.headers['X-Requested-With']怎麽用?Python FormRequest.headers['X-Requested-With']使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scrapy.FormRequest
的用法示例。
在下文中一共展示了FormRequest.headers['X-Requested-With']方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __repair_times_request_from_options
# 需要導入模塊: from scrapy import FormRequest [as 別名]
# 或者: from scrapy.FormRequest import headers['X-Requested-With'] [as 別名]
def __repair_times_request_from_options(self, item):
url = '/vehicle/component/repair-times/variant'
url = 'https://' + self.allowed_domains[0] + url
request = FormRequest(
url = url, formdata = {'item_id': item['item_id']}
)
request.headers['Content-Type'] = 'application/x-www-form-urlencoded'
request.headers['Accept'] = '*/*'
request.headers['X-Requested-With'] = 'XMLHttpRequest'
request.method = 'POST'
request.dont_filter = True
request.meta['option'] = item
request.callback = self.going_to_repair_times
self.__prepare_request(request)
return request
示例2: __options_request
# 需要導入模塊: from scrapy import FormRequest [as 別名]
# 或者: from scrapy.FormRequest import headers['X-Requested-With'] [as 別名]
def __options_request(self, code):
url = 'https://workshop.autodata-group.com/engine-code-form-api'
request = FormRequest(
url = url,
callback = self.going_to_options_or_repair_times,
formdata = {
'vehicle_id': code['mecnid'],
'engine_id': code['code'],
'engine_name': code['code'],
'back': ',/vehicle/component/rt&module=RT',
},
meta = {
'series': code,
},
dont_filter = True
)
self.__prepare_request(request)
request.method = 'POST'
request.headers['Content-Type'] = 'application/x-www-form-urlencoded'
request.headers['Accept'] = 'application/json, text/javascript, */*; q=0.01'
request.headers['X-Requested-With'] = 'XMLHttpRequest'
request.meta['code'] = code
return request