-2
私のC#コードに問題があります。私は修正する方法を知らない。私はちょうどjsonからすべてのタイトルを取得したい。 それは時のエラーを示した: "値の解析中に予期しない文字が発生しました。:パス ''、ライン 0、位置0"文字列にJSONをパースできません
var obj = JObject.Parse(jsons);
返されるデータは、GZIP圧縮形式であるよう
public void getTitle()
{
ArrayList myTitle = new ArrayList();
string url = "https://www.fiverr.com/gigs/endless_page_as_json?host=subcategory&type=endless_auto&category_id=3&sub_category_id=154&limit=48&filter=auto&use_single_query=true&page=1&instart_disable_injection=true";
using (var webClient = new System.Net.WebClient())
{
var jsons = webClient.DownloadString(url);
if (jsons != null)
{
var obj = JObject.Parse(jsons);
var urll = (string)obj["gigs"]["title"];
myNode1.Add(urll);
}
else
{
MessageBox.Show("nothing");
}
}
}
スワウワット値は 'var jsons'です。 – BWA
ウェブサイトを直接開くと、自動的に目的のJSONを含むファイルがダウンロードされます。あなたが望むのは、このファイルの中にあり、ウェブサイトのソースコードではないJSONを解析することです。 –
gzipの内容を解凍する必要があります(これはURLから取得したものです)、WebRequestを使用してその内容をAutomaticDecompressionプロパティにDecompressionMethods.GZipに設定することができます:http://stackoverflow.com/questions/33080674/read-httpwebreponse- using-getresponsestream-readtoend-return-strange-characters –