WebClient.DownloadString() 时出现 500 错误

500 error when WebClient.DownloadString()

我正在尝试使用 c# 解析 html 以获取此 site 中所有比赛的接球投注率。

我正在使用此代码在另一个网站上获取捕获匹配率并且运行良好。

Uri url = new Uri("https://1xbetm.mobi/LineFeed/Get1x2_VZip?sports=1&count=500&lng=tr&tf=1500000&tz=3&mode=4&country=190&getEmpty=true");
WebClient client = new WebClient();
string jsonOneXBetData = client.DownloadString(url);

但是当我将 Url 更改为

Uri url = new Uri("https://www.87tempobet.com");

我收到 500 错误:(

我尝试使用 Fiddler 4 阅读此网站请求操作,但找不到正确的 Url。

我尝试使用 Wireshark。但我不知道如何过滤本地请求并查看 url..

所以我不知道我需要做什么..你能帮帮我吗?

尝试按以下方式修饰您的请求 headers:

Uri url = new Uri("https://1xbetm.mobi/LineFeed/Get1x2_VZip?sports=1&count=500&lng=tr&tf=1500000&tz=3&mode=4&country=190&getEmpty=true");
System.Net.WebClient client = new System.Net.WebClient();
client.Headers.Add ("user-agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko");

string jsonOneXBetData = client.DownloadString(url);

编辑 1: 对于其他 url 似乎还需要 2 个 header 参数:

Uri url = new Uri("https://www.86tempobet.com?reloadlive=240671122&no_write_sess=1");
System.Net.WebClient client = new System.Net.WebClient();
client.Headers.Add ("user-agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko");
client.Headers.Add("method","POST");
client.Headers.Add("cookie","{cookie}");

string jsonOneXBetData = client.DownloadString(url);

编辑 2: 这是访问响应的完整请求 json :)

Uri url = new Uri("https://www.86tempobet.com?reloadlive=240671122&no_write_sess=1");
System.Net.WebClient client = new System.Net.WebClient();
client.Headers.Add ("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36");
client.Headers.Add("method","POST");
client.Headers.Add("cookie","visid_incap_1875943=C4HkVjo8RCCFldh593iChSbq6VsAAAAAQUIPAAAAAABzSYMXxV4TSKKZijRL24QX; incap_ses_277_1875943=ZnjKE7twmRYrT7s2YxvYAybq6VsAAAAAFdaEfL/KiNMUMywbnQeCNA==; GAMBLINGSESS=jfr3uadgl1ogv55c06ee6mvvs3fiv86p; nlbi_1875943=4NdhZ5rR80YChdm11QdqAQAAAAA3PlRp/yXvrsgK9rbvAEPs; _ga=GA1.2.449421393.1542056499; _gid=GA1.2.2110672116.1542056499; docscrollltop=0; LPVID=FkMTc4MDEwMzY3NDllNjU5; LPSID-34568906=eQOy1bjvTWS3lx1mTF5b3w");
client.Headers.Add("x-requested-with","XMLHttpRequest");
client.Headers.Add("betslip-hash","578c9b9896d955c14a698bf17937400a");
client.Headers.Add("content-type","application/x-www-form-urlencoded; charset=UTF-8");
client.Headers.Add("ajax-json","true");

string jsonOneXBetData = client.DownloadString(url);