响应谱 - 如何从网站获取数据

问题描述 投票:0回答:1

请有人帮助我,或者至少解释一下它是如何工作的......

这是关于这个网站的:http://mpk.wroc.pl/jak-jezdzimy/mapa-pozycji-pojazdow

当点击F12时,我们可以看到,我们有

enter image description here

如果输入cmd命令,例如:

curl http://mpk.wroc.pl/position.php --data \
  "busList%5Btram%5D%5B%5D=31&busList%5Btram%5D%5B%5D=32"

一切正常!

enter image description here

也出现在开发者模式的“响应”中。

enter image description here

但最后,当我想通过邮递员获取数据,设置

POST
并发送正确的数据(我认为)时,它什么也没有返回......

我也尝试过用C#制作

HTTPClient
WebClient
HttpWebRequest
/
Response
等,但什么也没有,我找不到任何数据...

http-headers httpclient httpresponse
1个回答
1
投票

这对我有用: 在邮递员中创建新的 Postrequest 到 http://mpk.wroc.pl/position.php 更改 x-www-form-urlencode 中的正文键值。

http://prntscr.com/le1deh

编辑

要在 C# 中实现此功能,您可以执行以下操作:

    static void Main(string[] args)
    {
        Dictionary<string, string> formvalues = new Dictionary<string, string>();
        formvalues.Add("busList[bus][]", "114");
        FormUrlEncodedContent body = new FormUrlEncodedContent(formvalues);
        sendPost(body);
        Console.ReadKey();
    }


    static async void sendPost(FormUrlEncodedContent content)
    {
        HttpClient client = new HttpClient();
        HttpResponseMessage response = await client.PostAsync("http://mpk.wroc.pl/position.php", content);
        string responseString = await response.Content.ReadAsStringAsync();
        Console.WriteLine(responseString);
    }
© www.soinside.com 2019 - 2024. All rights reserved.