Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function kodyPocztowe()
  2.  
  3.     Dim HTTP_SESJA As New ChilkatHttp
  4.     Dim success As Long
  5.     success = HTTP_SESJA.UnlockComponent("xxxxxxxxxxxxxxxxxxxx")
  6.    
  7.     If (success <> 1) Then
  8.         Debug.Print "Chilkat Error"
  9.         Exit Function
  10.     End If
  11.    
  12.     HTTP_SESJA.SendCookies = 1
  13.     HTTP_SESJA.SaveCookies = 1
  14.     HTTP_SESJA.Connection = "Keep-Alive"
  15.     HTTP_SESJA.RequiredContentType = "text/html"
  16.     HTTP_SESJA.AllowGzip = 1
  17.    
  18.     Dim req As New ChilkatHttpRequest
  19.    
  20.     'All part with JSON is just experimienting, idk if it is good
  21.    Dim jsonText As String
  22.     jsonText = "{""@context"": ""http://schema.org"", ""@type"": ""WebSite"", ""url"": ""http://www.poczta-polska.pl/"", ""potentialAction"": { ""@type"": ""SearchAction"", ""target"": ""http://www.poczta-polska.pl/?s={search_term}"", ""query-input"": ""required name=search_term""}"
  23.    
  24.     req.ContentType = "application/x-www-form-urlencoded"
  25.     req.httpVerb = "POST"
  26.     req.Path = "/index.php"
  27.     req.ContentType = "application/x-www-form-urlencoded"
  28.     req.AddHeader "Refferer", "http://kody.poczta-polska.pl/"
  29.     req.AddHeader "Accept", "application/json"
  30.    
  31.     req.AddParam "page", "kod"
  32.     req.AddParam "kod", "20-610"
  33.    
  34.     Dim requestMime As String
  35.     requestMime = req.GenerateRequestText()
  36.     Debug.Print requestMime
  37.    
  38.     Dim resp As New ChilkatHttpResponse
  39.     Set resp = Nothing
  40.    
  41.     Set resp = HTTP_SESJA.SynchronousRequest("kody.poczta-polska.pl", 80, 0, req)
  42.    
  43.     HTTP_SESJA.AcceptCharset = ""
  44.     HTTP_SESJA.UserAgent = ""
  45.     HTTP_SESJA.AcceptLanguage = ""
  46.     HTTP_SESJA.AllowGzip = 0
  47.    
  48.     'To test what is in resp
  49.    Open "C:\Documents and Settings\xxxxxxxxx\Pulpit\xxxxxxxxx\plik1.html" For Output As #1
  50.     Print #1, resp.BodyStr
  51.     Close #1
  52.    
  53.     Dim json As New ChilkatJsonObject
  54.     success = json.AppendString("JSON", "kod")
  55.    
  56.     json.EmitCompact = 0
  57.     success = req.LoadBodyFromString(json.Emit(), "utf-8")
  58.    
  59.     Set resp = HTTP_SESJA.PostJson("http://kody.poczta-polska.pl/", jsonText)
  60.    
  61.     'To test what is in resp
  62.    Open "C:\Documents and Settings\yyyyyyyyyy\Pulpit\yyyyyyyyyy\plik_po_JSON.html" For Output As #1
  63.     Write #1, resp.BodyStr
  64.     Close #1
  65.    
  66. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement