Skip to content

Instantly share code, notes, and snippets.

@rafikahmed
Created April 19, 2020 11:53
Show Gist options
  • Save rafikahmed/149668d2cae0175ea1e596b1f5e10e5f to your computer and use it in GitHub Desktop.
Save rafikahmed/149668d2cae0175ea1e596b1f5e10e5f to your computer and use it in GitHub Desktop.
import scrapy
from scrapy.http import FormRequest
class SaeedSpider(scrapy.Spider):
name = 'saeed'
start_urls = [
'https://seffaflik.epias.com.tr/transparency/uretim/gerceklesen-uretim/gercek-zamanli-uretim.xhtml']
def parse(self, response):
view_state = response.xpath(
'//input[@name="javax.faces.ViewState"]/@value').get()
yield scrapy.FormRequest.from_response(
response,
formid='j_idt22',
formdata={
'j_idt202': 'j_idt202',
'j_idt202:date1_input': '19.04.2020',
'j_idt202:date2_input': '19.04.2020',
'j_idt202:powerPlant_focus': '',
'j_idt202:powerPlant_input': '',
'j_idt202': 'goster:',
'j_idt202:dt_rppDD': '24:',
'javax.faces.ViewState': view_state,
},
callback=self.after_ok
)
def after_ok(self, response):
with open('saeed.htm', 'wb') as f:
f.write(response.body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment