Advertisement
so_hard

Untitled

Jan 17th, 2022
672
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import json
  2.  
  3. import scrapy
  4. from scrapy import Request
  5.  
  6.  
  7. class ExampleSpider(scrapy.Spider):
  8.     name = 'example'
  9.     # allowed_domains = ['example.com']
  10.     start_urls = ['http://example.com/']
  11.  
  12.     def start_requests(self):
  13.         url = 'https://www.powertochoose.org/en-us/service/v1/'
  14.  
  15.         headers = {
  16.             "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0",
  17.             "Accept": "*/*",
  18.             "Accept-Language": "uk,ru;q=0.8,en-US;q=0.5,en;q=0.3",
  19.             "Accept-Encoding": "gzip, deflate, br",
  20.             "Content-Type": "application/json; charset=utf-8",
  21.             "X-Requested-With": "XMLHttpRequest",
  22.             "Origin": "https://www.powertochoose.org",
  23.             "DNT": "1",
  24.             "Connection": "keep-alive",
  25.             "Referer": "https://www.powertochoose.org/en-us",
  26.             "Sec-Fetch-Dest": "empty",
  27.             "Sec-Fetch-Mode": "cors",
  28.             "Sec-Fetch-Site": "same-origin",
  29.             "TE": "trailers"
  30.         }
  31.  
  32.         cookies = {
  33.             "PowerToChoose.CurrentLanguage": "en-US"
  34.         }
  35.  
  36.         body = json.dumps({"parameters":
  37.             {
  38.                 "method": "TduCompaniesByZip",
  39.                 "zip_code": "75001",
  40.                 "include_details": False,
  41.                 "language": 0}
  42.         }
  43.         )
  44.  
  45.         yield Request(
  46.             url=url,
  47.             method='POST',
  48.             dont_filter=True,
  49.             cookies=cookies,
  50.             headers=headers,
  51.             body=body,
  52.         )
  53.  
  54.     def parse(self, response):
  55.         print(response.json())
  56.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement