我正在用Go编写解析器HTML。我需要获取HTML并将其传递给另一个函数。
我是这样做的:
receivedURL, err := http.Get("http://lavillitacafe.com/")
doc, err := goquery.NewDocumentFromReader(receivedURL.Body)
//"linkScrape" this is another function
contactURL := linkScrape(doc)
和
resp, err := http.Get("http://lavillitacafe.com/")
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
for true {
bs := make([]byte, 1014)
n, err := resp.Body.Read(bs)
contactURL := linkScrape(bs[:n])
if n == 0 || err != nil{
break
}
}
我该怎么办?
答案 0 :(得分:0)
这是根据您的用例调整的基本def index
if params[:search].present?
@topics = Topic.search(params[:search]).paginate(:page => params[:page], :per_page => 5)
flash[:notice] = "No records found based on the search." if @topics.blank?
else
@topics = Topic.all
flash[:notice] = "No records found in Database." if @topics.blank?
end
end
示例:
<div>
<%= will_paginate @topic, renderer: BootstrapPagination::Rails %>
</end>