json 和 vb.net 10

标签 json vb.net

我正在制作一个程序,它应该从不同的 json 中收集相同的信息。

例如来自:

http://steamcommunity.com/market/priceoverview/?appid=730&currency=3&market_hash_name=AK-47%20%7C%20Black%20Laminate%20%28Factory%20New%29

我得到 JSON:

{"success":true,"lowest_price":"84,66\u20ac"}

我要最低价! 到目前为止,我已经设法将这些信息放到我想要的地方!有一个或两个没问题,但我试图从不同的网址获得 1000 个不同的“最低价格”,这是一个问题!你能帮我找到一个更好的方法来收集所有这些价格吗? 我想把号码放在不同的标签上。

例如

Try
    Dim request As Net.HttpWebRequest
    Dim response As Net.HttpWebResponse = Nothing
    Dim reader As StreamReader
    request = DirectCast(WebRequest.Create("http://steamcommunity.com/market/priceoverview/?appid=730&currency=3&market_hash_name=AK-47%20%7C%20Black%20Laminate%20%28Factory%20New%29"), HttpWebRequest)
    response = DirectCast(request.GetResponse(), HttpWebResponse)
    reader = New StreamReader(response.GetResponseStream())
    Dim FN1 As String
    FN1 = reader.ReadToEnd()
    Dim jResults As JObject = JObject.Parse(FN1)
    Dim results As List(Of JToken) = jResults.Children().ToList()


    Dim json As JObject = JObject.Parse(FN1)
    Dim fn1ts As String = (json.Item("lowest_price"))
    label1.text = fn1ts
Catch ex As Exception
    label1.text = "N/A"
End Try

我从 json 中获取数字,但我想针对大约 1200 种不同的价格和标签执行此操作。有没有什么办法可以大规模地做到这一点?

问题是我重复了 200 个 url 的代码,当我测试我的程序时它确实加载了标签!我卡住了! (可能是在做程序)大约半小时什么都没做!我尝试使用 backgroundworked 但后来我记得它不能更改标签文本!

我想要一个我将通过 url 获取那些 json 数据 url 并将它们保存到一个 xml 文件中,当所有完成后将它们全部加载到标签中!

最佳答案

除了可以使用所有不同的参数外,没有其他方法可以做到这一点,例如AK47 黑色 Laminate Factory New into a table like

AK-47%20%7C%20Black%20Laminate%20%28Factory%20New%29

然后做一个查询

Select * FROM MarketItems 

像这样循环遍历它们

Foreach mUrl in marketUrl
    request = DirectCast(WebRequest.Create("http://steamcommunity.com/market/priceoverview/?appid=730&currency=3&market_hash_name=" + mUrl), HtmlWebRequest)

能否详细解释一下你遇到的错误是什么?

还有很多关于这个主题的话题:

Get the price of an item on Steam Community Market with PHP and Regex

Curl command to html or vb.net

从他们的角度来看,没有简单的方法可以做到这一点

关于json 和 vb.net 10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32003431/

相关文章:

c - 可以编译和运行 C 程序的 VB.NET 应用程序

linux - 是否可以为 Mac 和 Linux 构建 Visual Studio 应用程序?任何可用的 "extensions"

asp.net - 在 GridView 中使用分页维护排序

json swift4 如何设置结构?

php - HTTP Post 的 JSON 数据压缩

json - 有没有办法使用带有 sqlite 后端的 Flask sqlalchemy 保存 json

sql - 从VB.net调用存储过程超时错误

javascript - 处理 ListView 的嵌套 JSON 数据

java - RESTful 1-N 可选关系

asp.net-mvc - 我可以从操作过滤器获取操作的返回类型吗?