我需要向包含隐式令牌"__RequestVerificationToken"
的网站发送获取请求(会话)。之后,我想解析令牌,然后再次发送带有UserName,Password和解析后的hiddenToken的发布请求。
我知道如何在python中执行此操作,这是在python中实现的以下代码:
from bs4 import BeautifulSoup
import requests
session = requests.session() # Session Created
url ="some URL"
initial_login = session.get(url) # sending a get request to parse the token
soup = BeautifulSoup(initial_login.text,'html.parser')
token=soup.find('input') # used BeautifulSoup to find token
payload = { 'Username':'username','Password':'password','__RequestVerificationToken':token['value']}
login_done = session.post(url,data=payload)
login_cookie= login_done.cookies['APILogin']
请告诉我如何在C#中实现相同目标...