import scrapy
import json
from scrapy_splash import SplashRequest
from scrapy.http import FormRequest
from scrapy.utils.response import open_in_browser
class Spider1(scrapy.spiders.Spider):
name = 'scroll5'
api\_url = \['[https://tournaments.hjgt.org/tournament/TournamentResultSearch](https://tournaments.hjgt.org/tournament/TournamentResultSearch)'\]
start\_urls = \["[https://tournaments.hjgt.org/Tournament/Results/](https://tournaments.hjgt.org/Tournament/Results/)"\]
def parse(self, response):
token = response.xpath('//\*\[@name="\_\_RequestVerificationToken"\]/@value').extract\_first()
params = {
'\_\_RequestVerificationToken': token,
'PageIndex': '1',
'PageSize': '10',
'SearchForm.UpcomingPast': '',
'SearchForm.SearchString': '',
'SearchForm.StartDate': '',
'SearchForm.Distance': '',
'SearchForm.ZipCode': '',
'SearchForm.SeasonSelected': '',
}
c1 = '\_\_zlcmid=s1iC8Wd50nwSsZ; \_fbp=fb.1.1556404567829.398595254; \_\_atuvc=5%7C17%2C18%7C18; '
c2 = str(response.headers.getlist('Set-Cookie')\[0\])\[2:\].split(";")\[0\]
c3 = str(response.headers.getlist('Set-Cookie')\[2\])\[2:\].split(";")\[0\]
cookie = c1 + c2 + "; " + c3
yield FormRequest('[https://tournaments.hjgt.org/tournament/TournamentResultSearch](https://tournaments.hjgt.org/tournament/TournamentResultSearch)',method="POST",formdata = params,
headers = {
"Accept": 'application/json, text/javascript, */*; q=0.01',
"Accept-Encoding": 'gzip, deflate, br',
"Accept-Language": 'en-US,en;q=0.9,it;q=0.8',
"Connection": 'keep-alive',
# "Content-Length": '319',
"Content-Type": 'application/x-www-form-urlencoded; charset=UTF-8',
"Cookie": cookie,
"Host": 'tournaments.hjgt.org',
"Origin": 'https://tournaments.hjgt.org',
"Referer": 'https://tournaments.hjgt.org/Tournament/Results',
"User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36',
"X-Requested-With": 'XMLHttpRequest',
},
callback=self.finished)
def finished(self, response):
print(response.body)