0

am trying to Scrape data by importing a json to my vb.net from the web using parsehub api (https://www.parsehub.com/docs/ref/api/v2/?python#get-a-project)

am quite familiar with vb.net but all the examples given in the document section is either in curl,python,ruby or php.

the api code in curl is :

curl "https://www.parsehub.com/api/v2/projects/{PROJECT_TOKEN}/run"   -X POST \ 
  -d api_key=tElpQTK_W2mrPKYPl1gug0RE \ 
  -d start_url=http%3A%2F%2Fwww.example.com \ 
  -d start_template=main_template \ 
  -d start_value_override=%7B%22query%22%3A+%22San+Francisco%22%7D \ 
  -d send_email=1
{
  "project_token": "t-0WMEZ-Bc9sWGHAMsYvP7y4", 
  "run_token": "tCcB4hfFP6wvBRe2gwZv9aJp", 
  "status": "initialized", 
  "data_ready": false, 
  "start_time": "2015-02-03T23:09:38", 
  "end_time": null, 
  "pages": 0, 
  "md5sum": null, 
  "start_url": "http://www.example.com", 
  "start_template": "main_template", 
  "start_value": "{\"query\": \"San Francisco\"}"
}

i have so far tried doing this in vb.net

    Private Sub Button2_Click_1(sender As Object, e As EventArgs) Handles Button2.Click


  dgv2.Rows.Clear()
            Dim uri As Uri = New Uri("https://www.parsehub.com/api/v2/projects/{PROJECT_TOKEN}/run")
            Dim wc1 As System.Net.WebClient = New System.Net.WebClient()
            Dim VCItem As String = wc1.DownloadString(uri)
            Dim o As JObject = JObject.Parse(VCItem)
            Dim results As List(Of JToken) = o.Children().ToList


            'Try
            For Each item As JProperty In results
                    item.CreateReader()
                    If item.Value.Type = JTokenType.Array Then
                        For Each subitem As JObject In item.Values



                        dgv2.Rows.Add(subitem("leftlabelcells_value"), (subitem("hideextra_number")), (subitem("rightpositioncells_number")))


                    Next
                    End If

but i get a forbidden error and it does not work. any help would be greatly appreciated and stuck with this code for ages and i cant figure out what to do.

thank you.

1 Answers1

0

You want to replace {PROJECT_TOKEN} in your call with the actual token from your project, which you can find under the settings tab when editing your project.

Hope that helps. In the future, you can email us at support at parsehub dot com at any time, and you'll get a much faster response.

Sergiu Toarca
  • 2,617
  • 18
  • 23