[英]Scrapy - Retrieve Authentication Token from javascript script response
我需要有關此特定情況的幫助。
設想
我可以從<script>
標簽獲取這些信息
使用密鑰,我必須調用此端點
用於檢索存儲在 javascript 響應中的 SessionID
-- omitted
private._sessID='MYSESSIONID';
-- omitted
最后,使用這個 sessionId 並執行正確的 POST 操作,我可以在我需要的所有頁面中導航。
我的僵局
我可以使用帶有正則表達式的scrapy shell
regEx
所有步驟(並且一切正常),但我不知道如何在開始數據提取之前在 Z3CD13A277FBC2FEA5EF64364C8B6F85Z 蜘蛛中管理這些步驟。
有人可以幫我嗎?
您需要從基礎URL http://www.example.com/index.php
開始,通過調用它在啟動請求方法中調用它並寫入其其他回調並從其他端點提取信息過程。
您需要通過以下方式實現
class CrawlSpider(scrapy.CrawlSpider):
def parse_authentication_token(self, response):
//extract token or whatever require and then call supers parse
yield from super().parse()
def start_request(self):
return Request(url, callback=self.parse_authentication_token)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.