<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 "golang html parser." I used "golang" because just "go" 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 "goquery" 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't know that much about, be careful. If it'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'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't say always!). </p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传