慧聪网发布脚本早在今年2月份就写过,而昨天写的这串代码应是我写到如今的调峰之作,调试了一整夜,一点错误也没有发生。代码不仅有最新原创的随即调用指定目录内的随机TXT随机行,更实现了获取点颜色判断是否运行下一步或持续等待的的识别,对于慧聪网这样的打开新页面发信息的网站,可谓节省浏览器资源的重要举措。

本代码应用于:慧聪网--商品发布--建筑/建材》工程承包》项目承包,每条发布出的信息都在4星以上,值得一提是的是每个分类只能有100条产品(原先为1000条),所以设置运行100次后手动修改点坐标。

2016年11月17日晚完成第一次编写,2016年11月18日中午对脚本进行升级,包括添加页面是否加载完成的识别,发布内容时图片是否加载完成的识别,点击发布后是否发布成功的识别。

/*
版权声明 
1.本段代码由我编写,深山的鹿博客:www.noteet.com;
2.请将PC分辨率设置为1920x1080;
3.请关闭所有会弹窗的软件,如阿里旺旺、QQ,以防干扰脚本循环运行;
4.本脚本为:“慧聪网-发布产品”发布脚本,请使用搜狗浏览器“高速模式”;
5.请打开:后台商品发布,每天N条;
*/
Randomize
//调用文件取文件名函数
Function FindAllFiles(FolderPath)
    Dim AllFiles,fso,Folder,f,files
    AllFiles = ""
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set Folder = fso.getfolder(FolderPath)
    Set files = Folder.files
    For Each f In files
        AllFiles = AllFiles & f.name & ","
    Next
    Set fso = Nothing
    FindAllFiles = Split(AllFiles, ",")
End Function
//判断页面是否打开
IfColor 65,95,"2EA9FD",0 Then  
    Delay 50  
Else    
    Delay 500
End If
//点击商品发布
IfColor 466,281,"3B2EDB",0 Then
    Delay 50  
Else    
    Delay 3000
End If
IfColor 466,281,"3B2EDB",0 Then
    MoveTo 466, 281
    Delay 300
    LeftClick 1
    Delay 500    
Else    
    KeyPress "F5", 1
    Delay 3000
    MoveTo 466, 281
    Delay 300
    LeftClick 1
    Delay 300
End If
//点击我要发布
MoveTo 1351, 310
Delay 300
LeftClick 1
Delay 1000
IfColor 1341,305,"3B2EDB",0 Then
    LeftClick 1
    Delay 1000
Else    
    Delay 50
End If
//点击“下一步,填写商品信息”
IfColor 905,893,"413EF1",0 Then
    Delay 100
Else    
    Delay 5000
End If

IfColor 905,893,"413EF1",0 Then
    MoveTo 905,893
    Delay 300
    LeftClick 1
    Delay 1000
Else    
    MoveTo 403, 95
    Delay 300
    LeftClick 1
    Delay 300
    KeyPress "F5", 1
    Delay 300
    RestartScript
End If
IfColor 905,893,"413EF1",0 Then
    Delay 5000
Else    
    Delay 100
End If
//-----进入商品信息写入---- 
//写入项目名称
//点击进入输入
IfColor 584,214 ,"5C99FF",0 Then
    MoveTo 665,471
    Delay 300
    LeftClick 1
    Delay 300
Else    
    MoveTo 403, 95
    Delay 300
    LeftClick 1
    Delay 300
    KeyPress "F5", 1
    Delay 300
    RestartScript
End If
//写入前除错
KeyPress "A", 1
Delay 300
KeyPress "BackSpace", 1
Delay 300
//写入标题
//写入首端着关键词
Text = Plugin.File.ReadFileEx("F:\调用TXT\1.标题_关键词\屋面.txt")
MyArray = Split(Text, "|")
SayString MyArray(Int((UBound(MyArray) * Rnd) + 0))
//写入随机地名
文件夹路径 ="F:\调用TXT\1.标题_地名"
FileEx = FindAllFiles(文件夹路径)
If UBound(FileEx) > 0 Then
    随机文件名 = FileEx(int(rnd * UBound(FileEx)))
    TXT路径 = 文件夹路径 + "\" + 随机文件名
ElseIf UBound(FileEx) < 0 Then
    SayString (Cstr("文件夹 < "+ 文件夹路径 +" > 内无文章!"))
End If
//调用随机文档内的随机行
Text = Plugin.File.ReadFileEx(TXT路径)
MyArray = Split(Text, "|")
SayString MyArray(Int((UBound(MyArray) * Rnd) + 0))
//写入中间词
文件夹路径 ="F:\调用TXT\1.标题_细节"
FileEx = FindAllFiles(文件夹路径)
If UBound(FileEx) > 0 Then
    随机文件名 = FileEx(int(rnd * UBound(FileEx)))
    TXT路径 = 文件夹路径 + "\" + 随机文件名
ElseIf UBound(FileEx) < 0 Then
    SayString (Cstr("文件夹 < "+ 文件夹路径 +" > 内无文章!"))
End If
//调用随机文档内的随机行
Text = Plugin.File.ReadFileEx(TXT路径)
MyArray = Split(Text, "|")
SayString MyArray(Int((UBound(MyArray) * Rnd) + 0))
//写入关键词
Text = Plugin.File.ReadFileEx("F:\调用TXT\1.标题_关键词\屋面.txt")
MyArray = Split(Text, "|")
SayString MyArray(Int((UBound(MyArray) * Rnd) + 0))
//写入匹配语
Text = Plugin.File.ReadFileEx("F:\调用TXT\1.标题_匹配语\屋面.txt")
MyArray = Split(Text, "|")
SayString MyArray(Int((UBound(MyArray) * Rnd) + 0))
Delay 300
//复制标题
KeyDown 17, 1
KeyPress 65, 1
KeyUp 17, 1
Delay 300
KeyDown 17, 1
KeyPress 67, 1
KeyUp 17, 1
Delay 300
//写入项目描述(换行-粘贴)
KeyPress "Tab", 1
Delay 300
KeyDown 17, 1
KeyPress 86, 1
KeyUp 17, 1
Delay 300
//写入关键词
Text = Plugin.File.ReadFileEx("F:\调用TXT\1.标题_关键词\屋面.txt")
MyArray = Split(Text, "|")
SayString MyArray(Int((UBound(MyArray) * Rnd) + 0))
Delay 300
//写入适用标准(换行-调用)
KeyPress "Tab", 1
Delay 300
Text = Plugin.File.ReadFileEx("F:\调用TXT\1.标题_细节\用途.txt")
MyArray = Split(Text, "|")
SayString MyArray(Int((UBound(MyArray) * Rnd) + 0))
Delay 300
//写入所在地(换行-输入)
KeyPress "Tab", 1
Delay 300
SayString "江苏"
Delay 300
//写入承包地(换行-输入)
KeyPress "Tab", 1
Delay 300
SayString "福建"
Delay 300
//写入材质(换行-输入)
KeyPress "Tab", 1
Delay 300
SayString "低合金高强度"
Delay 300
//写入主营业务(换行-输入)
KeyPress "Tab", 1
Delay 300
SayString "工程施工"
Delay 300
//写入工程范围(换行-输入)
KeyPress "Tab", 1
Delay 300
SayString "景观建设"
Delay 300
//写入工程类型(换行-输入)
KeyPress "Tab", 1
Delay 300
SayString "钢结构工程"
Delay 300
//写入产品关键词(换行-调用2-1-1-1-1)
KeyPress "Tab", 2
Delay 300
Text = Plugin.File.ReadFileEx("F:\调用TXT\1.标题_关键词\屋面.txt")
MyArray = Split(Text, "|")
SayString MyArray(Int((UBound(MyArray) * Rnd) + 0))
KeyPress "Tab", 1
Delay 300
Text = Plugin.File.ReadFileEx("F:\调用TXT\1.标题_关键词\屋面.txt")
MyArray = Split(Text, "|")
SayString MyArray(Int((UBound(MyArray) * Rnd) + 0))
KeyPress "Tab", 1
Delay 300
Text = Plugin.File.ReadFileEx("F:\调用TXT\1.标题_关键词\屋面.txt")
MyArray = Split(Text, "|")
SayString MyArray(Int((UBound(MyArray) * Rnd) + 0))
KeyPress "Tab", 1
Delay 300
Text = Plugin.File.ReadFileEx("F:\调用TXT\1.标题_关键词\屋面.txt")
MyArray = Split(Text, "|")
SayString MyArray(Int((UBound(MyArray) * Rnd) + 0))
KeyPress "Tab", 1
Delay 300
Text = Plugin.File.ReadFileEx("F:\调用TXT\1.标题_关键词\屋面.txt")
MyArray = Split(Text, "|")
SayString MyArray(Int((UBound(MyArray) * Rnd) + 0))
//写入信息标题(换行-粘贴)
KeyPress "Tab", 1
Delay 300
KeyDown 17, 1
KeyPress 86, 1
KeyUp 17, 1
Delay 300
//页面下移
IfColor 441,968,"0000FF",0 Then
    MoveTo 54,902
    Delay 300
    LeftClick 1
    Delay 300
    KeyPress "PageDown", 1
    Delay 300
Else    
    MoveTo 403, 95
    Delay 300
    LeftClick 1
    Delay 300
    KeyPress "F5", 1
    Delay 300
    RestartScript
End If
//输入计量单位
IfColor 748,372,"F5F5FC",0 Then
    MoveTo 630,346
    Delay 300
    LeftClick 1
    Delay 300
    SayString "平方米"
    Delay 300
Else    
    MoveTo 403, 95
    Delay 300
    LeftClick 1
    Delay 300
    KeyPress "F5", 1
    Delay 300
    RestartScript
End If
//输入价格区间(换行-输入)
KeyPress "Tab", 3
Delay 300
SayString "1000"
Delay 300
//输入价格(换行-输入)
KeyPress "Tab", 1
Delay 300
SayString "135"
Delay 300
//输入供应总量(换行-输入)
KeyPress "Tab", 2
Delay 300
SayString "99999"
Delay 300
//点击商品图片
MoveTo 883, 664
Delay 100
IfColor 883, 664,"0000FF",0 Then
    LeftClick 1
    Delay 500
Else    
    MoveTo 403, 95
    Delay 300
    LeftClick 1
    Delay 300
    KeyPress "F5", 1
    Delay 300
    RestartScript
End If
//点击第一张图片
IfColor 632,472, "FFFFFF", 0 Then
    Delay 5000
Else    
    Delay 100
End If
IfColor 577, 339, "292CD5", 0 Then
    MoveTo 654,474
    Delay 300
    LeftClick 1
    Delay 500
Else    
    MoveTo 403, 95
    Delay 300
    LeftClick 1
    Delay 300
    KeyPress "F5", 1
    Delay 300
    RestartScript
End If
//随机点击第二张图片
a=Int((0 - 15 + 1) * Rnd + 15)
If a = 1 Then 
    MoveTo 752, 472
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 2 Then 
    MoveTo 869, 476
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 3 Then 
    MoveTo 985, 483
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 4 Then 
    MoveTo 1102, 469
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 5 Then 
    MoveTo 639, 614
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 6 Then 
    MoveTo 745, 626
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 7 Then 
    MoveTo 864, 618
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 8 Then 
    MoveTo 984, 621
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 9 Then 
    MoveTo 1112, 617
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 10 Then 
    MoveTo 620, 753
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 11 Then 
    MoveTo 756, 761
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 12 Then 
    MoveTo 869, 759
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 13 Then 
    MoveTo 988, 756
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 14 Then 
    MoveTo 1100, 754
    Delay 300
    LeftClick 1
    Delay 500
End If
Delay 500
//随机点击第三张图片
a=Int((0 - 15 + 1) * Rnd + 15)
If a = 1 Then 
    MoveTo 752, 472
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 2 Then 
    MoveTo 869, 476
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 3 Then 
    MoveTo 985, 483
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 4 Then 
    MoveTo 1102, 469
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 5 Then 
    MoveTo 639, 614
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 6 Then 
    MoveTo 745, 626
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 7 Then 
    MoveTo 864, 618
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 8 Then 
    MoveTo 984, 621
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 9 Then 
    MoveTo 1112, 617
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 10 Then 
    MoveTo 620, 753
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 11 Then 
    MoveTo 756, 761
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 12 Then 
    MoveTo 869, 759
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 13 Then 
    MoveTo 988, 756
    Delay 300
    LeftClick 1
    Delay 500
End If
If a = 14 Then 
    MoveTo 1100, 754
    Delay 300
    LeftClick 1
    Delay 500
End If
Delay 500
//点击确定
IfColor 1173,843, "4242E6", 0 Then
    MoveTo 1173,843
    Delay 300
    LeftClick 1
    Delay 500
Else    
    MoveTo 403, 95
    Delay 300
    LeftClick 1
    Delay 300
    KeyPress "F5", 1
    Delay 300
    RestartScript
End If
//页面下移
MoveTo 54,902
Delay 300
LeftClick 1
Delay 300
KeyPress "End", 1
Delay 300
//进入内容输入(判断是否出错)
IfColor 705,912, "413EF1", 0 Then
    MoveTo 601,243
    Delay 300
    LeftClick 1
    Delay 500
Else    
    MoveTo 403, 95
    Delay 300
    LeftClick 1
    Delay 300
    KeyPress "F5", 1
    Delay 300
    RestartScript
End If
//写入企业简介
文件夹路径 ="F:\调用TXT\2.内容_简介"
FileEx = FindAllFiles(文件夹路径)
If UBound(FileEx) > 0 Then
    随机文件名 = FileEx(int(rnd * UBound(FileEx)))
    TXT路径 = 文件夹路径 + "\" + 随机文件名
    内容 = Plugin.File.ReadFileEx(TXT路径)
    SayString (Cstr(内容))
ElseIf UBound(FileEx) < 0 Then
    SayString (Cstr("文件夹 < "+ 文件夹路径 +" > 内无文章!"))
End If
//隔离段
KeyPress "Enter", 1
Delay 300
//写入句子
文件夹路径 ="F:\调用TXT\2.内容_句子"
FileEx = FindAllFiles(文件夹路径)
If UBound(FileEx) > 0 Then
    随机文件名 = FileEx(int(rnd * UBound(FileEx)))
    TXT路径 = 文件夹路径 + "\" + 随机文件名
    内容 = Plugin.File.ReadFileEx(TXT路径)
    SayString (Cstr(内容))
ElseIf UBound(FileEx) < 0 Then
    SayString (Cstr("文件夹 < "+ 文件夹路径 +" > 内无文章!"))
End If
//隔离段
KeyPress "Enter", 1
Delay 300
//写出特定段落
文件夹路径 ="F:\调用TXT\2.内容_段落\特定"
FileEx = FindAllFiles(文件夹路径)
If UBound(FileEx) > 0 Then
    随机文件名 = FileEx(int(rnd * UBound(FileEx)))
    TXT路径 = 文件夹路径 + "\" + 随机文件名
    内容 = Plugin.File.ReadFileEx(TXT路径)
    SayString (Cstr(内容))
ElseIf UBound(FileEx) < 0 Then
    SayString (Cstr("文件夹 < "+ 文件夹路径 +" > 内无文章!"))
End If
//隔离段
KeyPress "Enter", 1
Delay 300
KeyDown 17, 1
KeyPress 86, 1
KeyUp 17, 1
Delay 300
//写出内容(内带移动or删除,默认移动)
文件夹路径 ="F:\调用TXT\2.内容_段落\"
FileEx = FindAllFiles(文件夹路径)
If UBound(FileEx) > 0 Then
    随机文件名 = FileEx(int(rnd * UBound(FileEx)))
    TXT路径 = 文件夹路径 + "\" + 随机文件名
    发布后路径 =文件夹路径 + "\已删除\"+ 随机文件名
    内容 = Plugin.File.ReadFileEx(TXT路径)
    SayString (Cstr(内容))
    Call Plugin.File.MoveFile(TXT路径, 发布后路径)
    //Call Plugin.File.DeleteFile(TXT路径)//删除TXT
ElseIf UBound(FileEx) < 0 Then
    SayString (Cstr("文件夹 < "+ 文件夹路径 +" > 内无文章!"))
End If
Delay 300
//写入单位重量
MoveTo 541, 546
Delay 300
LeftClick 1
Delay 300
SayString "45"
Delay 300
KeyPress "Enter", 1
Delay 300
//点击分类
MoveTo 633, 708
Delay 300
LeftClick 1
Delay 300
MoveTo 555, 829
Delay 300
LeftClick 1
Delay 300
//点击发布
MoveTo 739, 881
Delay 300
LeftClick 1
Delay 1500
//判断是否发布完成
IfColor 764,869, "413EF1", 0 Then
    Delay 4500
Else    
    Delay 100
End If
IfColor 1133,397 , " 015CFF", 0 Then
    Delay 50
Else    
    Delay 4500
End If
//关闭网页
MoveTo 403, 95
Delay 300
LeftClick 1
Delay 300
KeyPress "F5", 1
Delay 300