some more tweaks and fixes

This commit is contained in:
2020-01-15 18:00:58 +01:00
parent a09cb9c1cd
commit 35de12b3e9
6 changed files with 69 additions and 36 deletions

View File

@@ -15,7 +15,7 @@ import (
func page1(taskCtx context.Context) {
page := "PAGE1"
c, cancelCtxWTO := context.WithTimeout(taskCtx, 5*time.Second)
c, cancelCtxWTO := context.WithTimeout(taskCtx, 10*time.Second)
defer cancelCtxWTO()
// ensure that the browser process is started
@@ -45,7 +45,7 @@ func page2(taskCtx context.Context) {
return // currently not need
page := "PAGE2"
c, cancelCtxWTO := context.WithTimeout(taskCtx, 5*time.Second)
c, cancelCtxWTO := context.WithTimeout(taskCtx, 10*time.Second)
defer cancelCtxWTO()
// ensure that the browser process is started
@@ -67,7 +67,7 @@ func page2(taskCtx context.Context) {
func page3(taskCtx context.Context) {
page := "PAGE3"
c, cancelCtxWTO := context.WithTimeout(taskCtx, 5*time.Second)
c, cancelCtxWTO := context.WithTimeout(taskCtx, 10*time.Second)
defer cancelCtxWTO()
if err := chromedp.Run(c,
@@ -86,9 +86,11 @@ func page3(taskCtx context.Context) {
func page4(taskCtx context.Context) {
page := "PAGE4"
c, cancelCtxWTO := context.WithTimeout(taskCtx, 5*time.Second)
c, cancelCtxWTO := context.WithTimeout(taskCtx, 10*time.Second)
defer cancelCtxWTO()
makeScreenShot(taskCtx, page+"pre")
if err := chromedp.Run(c,
chromedp.WaitVisible(`#u_0_0`),
chromedp.SendKeys(`#u_0_0`, viper.GetString("login.passwd")),
@@ -108,7 +110,7 @@ func page4(taskCtx context.Context) {
func page5(taskCtx context.Context) {
page := "PAGE5"
c, cancelCtxWTO := context.WithTimeout(taskCtx, 5*time.Second)
c, cancelCtxWTO := context.WithTimeout(taskCtx, 10*time.Second)
defer cancelCtxWTO()
if err := chromedp.Run(c,
@@ -127,7 +129,7 @@ func page5(taskCtx context.Context) {
func page6(taskCtx context.Context) {
page := "PAGE6"
c, cancelCtxWTO := context.WithTimeout(taskCtx, 5*time.Second)
c, cancelCtxWTO := context.WithTimeout(taskCtx, 10*time.Second)
defer cancelCtxWTO()
// ensure that the browser process is started
@@ -148,7 +150,7 @@ func page6(taskCtx context.Context) {
func page7(taskCtx context.Context) {
page := "PAGE7"
c, cancelCtxWTO := context.WithTimeout(taskCtx, 5*time.Second)
c, cancelCtxWTO := context.WithTimeout(taskCtx, 10*time.Second)
defer cancelCtxWTO()
// ensure that the browser process is started
@@ -172,7 +174,7 @@ func page8(taskCtx context.Context) (postID string, fbPost *FBPostData, err erro
fbPost = nil
err = nil
c, cancelCtxWTO := context.WithTimeout(taskCtx, 10*time.Second)
c, cancelCtxWTO := context.WithTimeout(taskCtx, 15*time.Second)
defer cancelCtxWTO()
const function1 = `(function(d) {
@@ -265,6 +267,7 @@ func page9(taskCtx context.Context, postID string) {
}
func sendRandomText() string {
var randomText []string = viper.GetStringSlice("comment_on_posts")
s := rand.NewSource(time.Now().Unix())
r := rand.New(s) // initialize local pseudorandom generator
return randomText[r.Intn(len(randomText))]