<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: fontexD</title>
    <description>The latest articles on DEV Community by fontexD (@fontexd).</description>
    <link>https://dev.to/fontexd</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F932273%2Ff37f44a0-2494-40b5-93cf-491634d40482.png</url>
      <title>DEV Community: fontexD</title>
      <link>https://dev.to/fontexd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fontexd"/>
    <language>en</language>
    <item>
      <title>Go Scrape Json and get value response</title>
      <dc:creator>fontexD</dc:creator>
      <pubDate>Sun, 25 Sep 2022 17:26:35 +0000</pubDate>
      <link>https://dev.to/fontexd/go-scrape-json-and-get-value-response-158n</link>
      <guid>https://dev.to/fontexd/go-scrape-json-and-get-value-response-158n</guid>
      <description>&lt;p&gt;Im trying to create a app that scrapes given urls to a function and returns the key/value but i dont get that data here is my code&lt;/p&gt;

&lt;p&gt;package main&lt;/p&gt;

&lt;p&gt;import (&lt;br&gt;
    "encoding/json"&lt;br&gt;
    "fmt"&lt;br&gt;
    "net/http"&lt;br&gt;
)&lt;/p&gt;

&lt;p&gt;// Which sites to scrape for health&lt;br&gt;
// Get request&lt;/p&gt;

&lt;p&gt;type response struct {&lt;br&gt;
    Name  string &lt;code&gt;json:"key"&lt;/code&gt;&lt;br&gt;
    Value string &lt;code&gt;json:"value"&lt;/code&gt;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;func getData(x string) string {&lt;br&gt;
    var data response&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resp, err := http.Get(x)
if err != nil {
    fmt.Print(err)
    return x
}
defer resp.Body.Close()
err = json.NewDecoder(resp.Body).Decode(&amp;amp;data)
if err != nil {
    fmt.Print(x, data.Value, err)
    return x
}

return x
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
func main() {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x := "http://127.0.0.1:8080/health"
result := getData(x)
fmt.Printf(result)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
