Dünkünün pembesi
Python :https://www.turkhackteam.org/python/1957653-yardim-merkezindeki-cevaplanmamis-konulari-cekmek.html
Kod:
package main
import (
"fmt"
"io/ioutil"
"net/http"
"regexp"
"strings"
"golang.org/x/text/encoding/charmap"
)
func main() {
fmt.Println(yardimmerkezi())
}
func postint(text string) string {
new := strings.Split(text, ",")[0]
new = strings.Split(new, " ")[1]
return new
}
func yardimmerkezi() []string {
client := http.Client{}
hostName := "https://www.turkhackteam.org/tht-yardim-merkezi/"
req, _ := http.NewRequest("GET", hostName, nil)
req.Header.Add("User-Agent", "Mozilla/5.0")
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
decoder := charmap.ISO8859_9.NewDecoder()
iso_body, _ := decoder.Bytes(body)
myRegexLink := regexp.MustCompile(`href="([^"]+)" id="thread_title_[0-9]+"`)
links := myRegexLink.FindAllSubmatch(iso_body, -1)
myRegex := regexp.MustCompile(`class="alt2" title="(.*?)"`)
posts := myRegex.FindAllSubmatch(iso_body, -1)
myRegexDate := regexp.MustCompile(`<div class="mob-date-thread"[^>]*>(.*?)</div>`)
dates := myRegexDate.FindAllSubmatch(iso_body, -1)
var result []string
for i := 12; i < len(links); i++ {
uri := string(links[i][1])
post := string(postint(string(posts[i][1])))
date := string(dates[i][1])
ka := strings.Contains(date, "önce")
if !ka {
return result
}
if post == "0" {
result = append(result, uri)
}
}
return result
}
Python :https://www.turkhackteam.org/python/1957653-yardim-merkezindeki-cevaplanmamis-konulari-cekmek.html