我正在尝试制作一个程序,以检查多个电话公司中是否有可用的电话号码。我正在用C#语言编写此程序。 最近,我成功地从4家公司中的3家成功提取了数据,但我找不到从上一家获得状态的方法。
这是我遇到困难的网站的URL:
https://www.partner.co.il/internet_and_phone/asterisk。
用户应该输入所需的4位数字,然后单击按钮,然后打印适当的消息。
深入研究他们的文件后,我可以看到他们的代码正在发送带有以下数据的POST请求:{Number:(number),Action:“ checkNumberStatus”}。
这是他们的要求:
@font-face {
font-family: 'Fontil Sans';
src: url('../assets/fonts/FontinSans/Fontin_Sans_R.otf') format('opentype');
}
@import '~@angular/material/prebuilt-themes/indigo-pink.css';
@import '~@angular/material/theming';
$custom-typography: mat-typography-config(
$font-family: 'Fontil Sans, monospace',
$headline: mat-typography-level(32px, 48px, 700),
$body-1: mat-typography-level(16px, 24px, 500)
);
@include angular-material-typography($custom-typography);
我对请求有点陌生,这是我要做的:
jQuery.post("/OrangeMinisites/Handlers/AsteriskRegulation.ashx", {
Number: number,
Action: "CheckNumberStatus"
}, function(data) {
var response = eval('(' + data + ')');
if (response.Success) {
jQuery("#loader").hide();
jQuery("[data-number-status='available']").show();
}
else {
jQuery("#loader").hide();
if (response.ErrorMessage == "notvalid") {
jQuery("[data-number-status='notvalid']").show();
}
else if (response.ErrorMessage == "unavailable") {
jQuery("[data-number-status='unavailable']").show();
}
else if (response.ErrorMessage == "networkusage") {
jQuery("[data-number-status='networkusage']").show();
}
else {
jQuery("#errSpan").text(response.ErrorMessage);
jQuery("[data-number-status='error']").show();
}
}
});
不幸的是,输出仅为:
class Program
{
static void Main(string[] args)
{
//Cellcom cellcom = new Cellcom("https://www.cellcom.co.il/support/stars/");
//Console.WriteLine(cellcom.GetStarValue("9294"));
//Hot hot = new Hot("https://www.hot.net.il/PageHandlers/GetStarNumbers.aspx?c=", "&Lcid=1037");
//Console.WriteLine(hot.GetStarStatus("9294"));
//Bezeq bezeq = new Bezeq("https://netivr.bezeq.co.il/stars/CheckNumber.ashx");
//Console.WriteLine(bezeq.GetStarStatus("9294"));
Partner partner = new Partner("https://www.partner.co.il/internet_and_phone/asterisk/OrangeMinisites/Handlers/AsteriskRegulation.ashx");
Console.WriteLine("status: " + partner.GetStarStatus("9294"));
}
}
class Partner
{
private string url;
private static readonly HttpClient client = new HttpClient();
private string respondString;
public Partner(string url)
{
this.url = url;
}
public string GetStarStatus(string star)
{
var request = (HttpWebRequest)WebRequest.Create(this.url);
var postData = new Dictionary<string, string>{ { "Number", star }, { "Action", "checkNumberStatus" } };
var content = new FormUrlEncodedContent(postData);
continueRequestAsync(content);
//var data = Encoding.ASCII.GetBytes(postData);
return this.respondString;
}
public async void continueRequestAsync(FormUrlEncodedContent content)
{
var response = await Partner.client.PostAsync(this.url, content);
var responseString = await response.Content.ReadAsStringAsync();
this.respondString = responseString;
}
}
我认为为什么它不起作用有几个原因:
即使这个问题冗长,也请尝试帮助我。
(我已竭尽所能,希望我的问题很好。如果这个问题不够详细,我不知道是哪一个。)
非常感谢