72 lines
2.8 KiB
Go
72 lines
2.8 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"html"
|
|
"io/ioutil"
|
|
"net/url"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
var (
|
|
testStyleURL string = `https\3a //scontent.fbre2-1.fna.fbcdn.net/v/t1.0-9/cp0/e15/q65/s720x720/82084740_2291078311193333_4974989532400189440_o.jpg?_nc_cat\3d 1\26 efg\3d eyJpIjoidCJ9\26 _nc_ohc\3d YFSkDqncwkYAX9wymCm\26 _nc_ht\3d scontent.fbre2-1.fna\26 oh\3d a31ebd3e26518967fa5222b85098d300\26 oe\3d 5EAF6A0D`
|
|
testMoopURL string = `/story.php?story_fbid=2291080917859739&id=1574763202824851&_ft_=mf_story_key.2291080917859739%3Atop_level_post_id.2291080917859739%3Atl_objid.2291080917859739%3Acontent_owner_id_new.1574763202824851%3Athrowback_story_fbid.2291080917859739%3Apage_id.1574763202824851%3Aphoto_id.2291078307860000%3Astory_location.4%3Astory_attachment_style.photo%3Apage_insights.%7B%221574763202824851%22%3A%7B%22page_id%22%3A1574763202824851%2C%22actor_id%22%3A1574763202824851%2C%22dm%22%3A%7B%22isShare%22%3A0%2C%22originalPostOwnerID%22%3A0%7D%2C%22psn%22%3A%22EntStatusCreationStory%22%2C%22post_context%22%3A%7B%22object_fbtype%22%3A266%2C%22publish_time%22%3A1578841213%2C%22story_name%22%3A%22EntStatusCreationStory%22%2C%22story_fbid%22%3A%5B2291080917859739%5D%7D%2C%22role%22%3A1%2C%22sl%22%3A4%2C%22targets%22%3A%5B%7B%22actor_id%22%3A1574763202824851%2C%22page_id%22%3A1574763202824851%2C%22post_id%22%3A2291080917859739%2C%22role%22%3A1%2C%22share_id%22%3A0%7D%5D%7D%7D&__tn__=-R`
|
|
)
|
|
|
|
func Test_main(t *testing.T) {
|
|
genURL := strings.ReplaceAll(testStyleURL, `\3a `, `:`)
|
|
genURL = strings.ReplaceAll(genURL, `\3d `, `=`)
|
|
genURL = strings.ReplaceAll(genURL, `\26 `, `&`)
|
|
fmt.Printf("%#v\n", genURL)
|
|
}
|
|
|
|
func TestCronTask(t *testing.T) {
|
|
fmt.Printf("%#v", cronTask())
|
|
}
|
|
|
|
func Test_moop(t *testing.T) {
|
|
|
|
genURL, err := url.Parse(html.UnescapeString(testMoopURL))
|
|
if err != nil {
|
|
t.Errorf("%#v", err.Error())
|
|
}
|
|
|
|
fmt.Printf("%#v\n", genURL)
|
|
for i, query := range genURL.Query() {
|
|
fmt.Printf("%s : %#v\n", i, query)
|
|
if i == "_ft_" {
|
|
text := ""
|
|
for _, txt := range query {
|
|
text = text + txt
|
|
}
|
|
for in, mtext := range strings.SplitN(text, ":", 10) {
|
|
allText := strings.Split(mtext, ".")
|
|
fmt.Printf("%d ::: %s : %s\n", in, allText[0], allText[1])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestParse(t *testing.T) {
|
|
url := "https://www.facebook.com/herowarsgame/posts/"
|
|
//url := "https://www.facebook.com/jayasaro.panyaprateep.org/posts/1095007907274561:0"
|
|
//url := "https://www.facebook.com/jayasaro.panyaprateep.org/photos/a.318290164946343.68815.318196051622421/1119561951485823/?type=3"
|
|
//result, err := Parse(url)
|
|
dat, err := ioutil.ReadFile("./2020-01-14T17:07:58+01:00-PAGE8-content.html")
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
//fmt.Print(string(dat))
|
|
|
|
post, err := ParsePost(string(dat), url)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
t.Log(post)
|
|
fmt.Printf("%#v", post)
|
|
|
|
}
|