本文整理汇总了Golang中ml/net/http.Session.Get方法的典型用法代码示例。如果您正苦于以下问题:Golang Session.Get方法的具体用法?Golang Session.Get怎么用?Golang Session.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ml/net/http.Session
的用法示例。
在下文中一共展示了Session.Get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: openThread
func openThread(session *http.Session, user String) {
doc := openPage(session, FORUM_URL)
threads := []*goquery.Selection{}
doc.Find("tbody").Each(func(i int, s *goquery.Selection) {
id_, exist := s.Attr("id")
id := String(id_)
if exist && id.StartsWith("normalthread_") {
threads = append(threads, s)
}
})
if len(threads) == 0 {
Raise("empty thread")
}
index := random.IntRange(0, len(threads))
t := threads[index].Find("a.s.xst")
href, ok := t.Attr("href")
if ok == false {
Raise("can't find thread addr")
}
credit := String(doc.Find("#extcreditmenu").Text())
console.SetTitle(credit.Split(":", 1)[1])
Printf("[%s][%s] %s @ %s\n", time.Now().Format("2006-01-02 15:04:05"), user, credit, t.Text())
session.Get(BASE_URL + href)
}
示例2: openPage
func openPage(session *http.Session, url String) (doc *goquery.Document) {
resp := session.Get(url)
doc, err := goquery.NewDocumentFromReader(strings.Decode(resp.Content, resp.Encoding).NewReader())
RaiseIf(err)
return
}
示例3: openPage
func openPage(session *http.Session, url String) (doc *goquery.Document, err error) {
resp, err := session.Get(url)
if err != nil {
return nil, err
}
doc, err = goquery.NewDocumentFromReader(strings.Decode(resp.Content, resp.Encoding).NewReader())
return
}
示例4: logout
func logout(session *http.Session) {
doc := openPage(session, FORUM_URL)
doc.Find("a").Each(func(i int, s *goquery.Selection) {
href_, exist := s.Attr("href")
href := String(href_)
if exist && href.Contains("action=logout") {
session.Get(BASE_URL + href)
}
})
}
示例5: logout
func logout(session *http.Session) error {
doc, err := openPage(session, FORUM_URL)
if err != nil {
return err
}
doc.Find("a").Each(func(i int, s *goquery.Selection) {
href_, exist := s.Attr("href")
href := String(href_)
if exist && href.Contains("action=logout") {
session.Get(BASE_URL + href)
}
})
return nil
// logout = logout and page.find(lambda e : e.get('href') and 'action=logout' in e['href'])
// if logout:
// yield from http.request('get', BASE_URL + logout['href'])
}