2017-10-12 1 views
-1

サイトからオーダーを解析したい。 ajax経由でロードしているリクエストとそのリクエストは次のようになります。スクラップマルチパートフォームデータリクエスト

-----------------------------1662842698634843362034232373 Content-Disposition: form-data; name="query" { orders(skip: 30, limit: 30, filter: {less3bids: false,withoutMyBids: false,title: "tests",contractual: true}) { total filtered orders { id type { id name } } } } -----------------------------1662842698634843362034232373--

私はどのように送信要求が必要なのか分かりません。私が試した:

def after_login(self, content): 
    body = '''-----------------------------1662842698634843362034232373 
       Content-Disposition: form-data; name="query" 
       { 
       orders(skip: 30, limit: 30, filter: {less3bids: false,withoutMyBids: false,title: "tests",contractual: true}) { 
       total 
       filtered 
       orders { 
       id 
       type { id name } 
       } 
       } 
       } 
      -----------------------------1662842698634843362034232373-- 
      ''' 
      return scrapy.Request(
       url="https://somesite.com/graphqlapi?", 
       method='POST', 
       body=body, 
       headers={ 
        'Content-Type': 'multipart/form-data; boundary=---------------------------1662842698634843362034232373' 
       }, 
       callback=self.parse_orders) 

しかし、サイトはエラーを返します:Firefoxの検査官が間違ったのparamsを返すよう

Syntax Error GraphQL request (1:1) Unexpected <EOF>\n\n1: \n ^\n 

答えて

0

が見えます。クロムからparamsをコピーしたとき、要求は正常に動作します。