Simple way to get table data in the request

blov · · 522 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I am new in Golang and I have my simple HTML table with IDs and URLs.</p> <p>When I post, I have it in request.Form</p> <p>map[url:[<a href="http://www.example.net/">http://www.example.net/</a> <a href="http://www.example2.net/">http://www.example2.net/</a>] url_id:[1 2]]</p> <p>Any simple way to not parse it manually? any method to join it?</p> <p>Thanks in advance.</p> <hr/>**评论:**<br/><br/>izuriel: <pre><p>I went to Google and searched &#34;golang html parser.&#34; I used &#34;golang&#34; because just &#34;go&#34; tends to return fewer relevant results, (IMO). The first result is a godoc page for golang.org/x/net/http which provides a parser for HTML fragments from an io.Reader. Then the second result for a library called &#34;goquery&#34; which could be more of what your looking for. So a simple Google search would have already answered your question. So ask Google first!</p> <p>Now, if your scraping an HTML page chances are your not intended to be doing so so, depending on user agreements or other things legal I don&#39;t know that much about, be careful. If it&#39;s yours, or your companies you should make this a data endpoint and avoid scraping. Lastly there are services that turn arbitrary webpages into JSON end points that you can look into as well. </p> <p>Final note, try, try, try to not scrape. Scraping is far more fickle than other ways to get data. If classes or elements change your program breaks. And it&#39;s more likely that the page can change than an API. Most of the time the API itself implies some form of consistency (I didn&#39;t say always!). </p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

522 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传