html字段隐藏,如何刮取动态隐藏的HTML字段(UuViewState)值?
我在代碼中完全實現了請求,但在FormRequest中意識到VIEWSTATE和EVENTVALIDATION是動態的,它們隨每個請求而變化。我想做的是刮去它們以便在下一個請求中提供它們。在
這兩個字段都在HTML代碼中提供,但隱藏了<;the __VIEWSTATE>;。我試著使用硒,但沒有任何有用的結果。在start_urls = [
'http://www.gasunietransportservices.nl/en/dataport-pages/lng-terminals/nominations',
'http://dataport.gastransportservices.nl/default.aspx?ReportPath=%2fTransparency%2fNominationsPerNetworkpoint&ReportTitle=NominationsPerNetworkpoint&TransparencySegment=06',
]
def start_requests(self):
yield Request(
url=self.start_urls[0],
callback=self.parse
)
def parse(self, response):
sel = Selector(response)
#import ipdb; ipdb.set_trace()
view_state = sel.xpath('//input[@id="__VIEWSTATE"]/@value').extract()
event_validation = sel.xpath('//input[@id="__EVENTVALIDATION"]/@value').extract()
formdata = {
'scriptManager': 'scriptManager|ReportViewerControl$ctl09$Reserved_AsyncLoadTarget',
'__EVENTTARGET': 'ReportViewerControl$ctl09$Reserved_AsyncLoadTarget',
'__EVENTARGUMENT': '',
'__VIEWSTATE': '{}'.format(view_state[0]),
'__VIEWSTATEGENERATOR': 'CA0B0334',
'__EVENTVALIDATION': '{}'.format(event_validation[0]),
'ReportViewerControl$ctl03$ctl00': '',
'ReportViewerControl$ctl03$ctl01': '',
'ReportViewerControl$ctl10': 'ltr',
'ReportViewerControl$ctl11': 'standards',
'ReportViewerControl$AsyncWait$HiddenCancelField': 'False',
'ReportViewerControl$ctl04$ctl03$txtValue': 'LNG Terminals',
'ReportViewerControl$ctl04$ctl05$txtValue': 'ROTTERDAM (GATE) - 301345',
'ReportViewerControl$ctl04$ctl07$txtValue': '5-10-2015 0:00:00',
'ReportViewerControl$ctl04$ctl09$ddValue': '1',
'ReportViewerControl$ctl04$ctl11$txtValue': '6-10-2015 0:00:00',
'ReportViewerControl$ctl04$ctl13$ddValue': '1',
'ReportViewerControl$ctl04$ctl15$ddValue': '1',
'ReportViewerControl$ctl04$ctl17$ddValue': '1',
'ReportViewerControl$ctl04$ctl05$divDropDown$ctl01': 'on',
'ReportViewerControl$ToggleParam$store': '',
'ReportViewerControl$ToggleParam$collapse': 'false',
'ReportViewerControl$ctl05$ctl00$CurrentPage': '',
'ReportViewerControl$ctl08$ClientClickedId': '',
'ReportViewerControl$ctl07$store': '',
'ReportViewerControl$ctl07$collapse': 'false',
'ReportViewerControl$ctl09$VisibilityState$ctl00': 'None',
'ReportViewerControl$ctl09$ScrollPosition': '',
'ReportViewerControl$ctl09$ReportControl$ctl02': '',
'ReportViewerControl$ctl09$ReportControl$ctl03': '',
'ReportViewerControl$ctl09$ReportControl$ctl04': '100',
'__ASYNCPOST': 'true',
}
yield FormRequest(
url=self.start_urls[1],
formdata=formdata,
callback=self.parse_filter,
)
def parse_filter(self, response):
import ipdb; ipdb.set_trace()
總結
以上是生活随笔為你收集整理的html字段隐藏,如何刮取动态隐藏的HTML字段(UuViewState)值?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 招行信用卡年费多少 想免年费的看过来
- 下一篇: html5引擎笔试题,最新!HTML5经