落伍者(一心一意)
Ecranesoft
- 贡献
- 152
- 鲜花
- 0
- 注册时间
- 2001-10-10
|
楼主 |
发表于 2006-6-9 01:13:21
|
来自 中国安徽安庆
动网自动发贴源代码
---------------------------------------------------
下面是一个简单的例子,演示通过wb:go自动post发贴(不需要页面提交)。
关于这个函数的用法可以参考贴子:http://www.yhhe.net/bbs/dispbbs.asp?boardID=4&ID=2427&page=1
- <?xml version="1.0" encoding="gb2312" ?>
- <ApeML LID="CHS" MD="0" 抓屏模式="0" 名称="动网自动发贴" 作者="模拟精灵 2005" 信息窗口="true" 速度="10" 循环次数="1" 自定义属性="用户选项=0">
- <!--创建时间:2006年05月04日-10:51-->
- <脚本区块 语言="LAScript" 名称="init" 延时="0" 启用="true" 编辑密钥="" 运行公钥="">
- <![CDATA[
- --在这里设置发贴参数
- _site = "http://www.****.com/bbs";
- _username="测试用户名";
- _body = "自动发的贴子";
- _topic = "模拟精灵发贴测试";
- _passwd ="1111111111111111111";
- -- setDL函数可能用到的常量
- _DLCTL_VIDEOS = 0x00000020 --视频
- _DLCTL_NO_RUNACTIVEXCTLS = 0x00000200 --禁止运行ActiveX 控件
- _DLCTL_NOFRAMES = 0x00080000 --禁用框架
- _DLCTL_NO_SCRIPTS = 0x00000080 --禁用脚本
- --创建web窗体
- wb2 = web.new(_site.."/login.asp");
- --读取用户名输入框
- ele = wb2:getEle("username");
- --输入用户名
- ele:setAttribute("value",_username);
- --读取密码输入框
- ele = wb2:getEle("password");
- --输入密码
- ele:setAttribute("value",_passwd);
- web.show(wb2,true)
- win.messagePrint("请登录论坛......")
- --等待登录
- wb2:wait("action=chk");
- --wb2:setDL(_DLCTL_VIDEOS |_DLCTL_NO_RUNACTIVEXCTLS |_DLCTL_NOFRAMES |_DLCTL_NO_SCRIPTS);
- wb2:setSilent(true,true,true,true)
- win.messagePrint("正在发贴.......")
- --这里用的是wb2:go函数自动post,不需要页面提交的方式。
- wb2:go(_site.."/SavePost.asp?Action=snew&boardid=4","_self","Referer: ".._site.."/post.asp?action=new&boardid=4\r\nContent-Type: application/x-www-form-urlencoded","upfilerename=&Body=".._body.."&dvbbs=DvForum&star=1&page=1&TotalUseTable=dv_bbs1&username=".._username.."&passwd=**********&font=&topic=".._topic.."&Expression=face1.gif&autofix=1&GetPostType=&ToMoney=&Buy_Orders=-1&Buy_VIPType=0&Buy_UserList=&signflag=yes&emailflag=0")
- wb2:wait("")
- win.messagePrint("发贴完成")
- ]]>
- </脚本区块>
- <数据区块 />
- </ApeML>
复制代码
自动滚动窗口抓取网页全图的源代码
---------------------------------------------------
- <?xml version="1.0" encoding="gb2312" ?>
- <ApeML LID="CHS" MD="0" 抓屏模式="0" 名称="网页抓图演示(自动滚屏)" 作者="精灵加加 yhhe.net" 信息窗口="true" 速度="30" 循环次数="1" 自定义属性="用户选项=0">
- <!--抓网页全图示例
- 抓图时自动滚屏合成图片-->
- <脚本区块 语言="LAScript" 名称="init" 延时="0" 启用="true" 编辑密钥="" 运行公钥="">
- <![CDATA[
- if(_VERSION<2005700)then
- win.messageBox("本程序必须模拟精灵v7.0以上版本支持");
- end;
- import("std");--导入std库,不导入也没关系,主要是导入_MIX_SRCCOPY,不过_MIX_COPY为0,不导入为nil值作为参数还是转换为0的
- _url = win.inputBox("请指定要抓屏生成图片的网址","自动滚屏网页抓图小工具");
- wb = web.new(_url); --创建一个web窗体
- wb:setTitle(false); --不要边框标题栏这些
- wb:show(true); --显示web窗体
- local hwnd = wb:getWindow(); --得到窗口句柄
- local x,y,x2,y2 = win.getRect(hwnd); --得到窗口大小
- local w = x2 - x; --算出宽
- local h = y2 -y; --算出高
- win.setForeground(hwnd);delay(1000); --前置窗体
- img = image.new( w,h ); --创建图片
- img:capture(hwnd,0,0,w,h); --抓取窗口图片,坐标当澹是0 x 0
- function capweb()
-
- img2 = image(img);--复制原来的img
- img = image.new(img:width(),img:height()+h); --增加图片一页的高度
- img:mix(img2,_MIX_COPY,0,0); --把原来的图片贴到新图片的上面
-
- local imgweb = image.new( w,h );
- win.setForeground(hwnd);delay(100);
- imgweb:capture(hwnd,0,0,w,h);
- img:mix(imgweb,_MIX_COPY,0,img:height()-h); --把新图片补到下面
-
- end;
- function capweb2(t)
- local th=t;
-
- img2 = image(img);--复制原来的img
- img = image.new(img:width(),img:height()+th);--增加图片不足一页的高度
- img:mix(img2,_MIX_COPY,0,0);--把原来的图片贴到新图片的上面
-
- local imgweb = image.new( w,th );
- win.setForeground(hwnd);delay(100);
- imgweb:capture(hwnd,0,h-th,w,th);
-
- img:mix(imgweb,_MIX_COPY,0,img:height()-th);--把新图片补到下面
- end;
- local js = [[
- var LAScript = external;
- var currentpos = -1;
- var n = 0;
- function xbody()
- {
- if( document.documentElement && document.documentElement.scrollTop )
- return document.documentElement;
- return document.body;
- }
- while(currentpos!=xbody().scrollTop)
- {
- currentpos = xbody().scrollTop;
- window.scroll(0,currentpos + ]]..h..[[);
- n = xbody().scrollTop-currentpos;
- if (n<]]..h..[[)
- {
- LAScript.capweb2(n); //直接调用LAScript里的抓屏函数,这里是不足一屏的高度
- break;
- }
- else
- {
- LAScript.capweb();//直接调用LAScript里的抓屏函数
- }
- }
- ]]
- wb:doScript(js,"javascript");
- local url = urlparse.new(_url);--创建一个网址分析器
- local deffile = url:path(); --取到网址中的文件路径
- if(deffile )then
- deffile = string.gsub(deffile,"/","\");
- deffile = win.pathName( deffile ); --取到文件名
- else
- deffile = "web"
- end;
- deffile = deffile..".jpg"; --生成默认的文件名
- --打开保存文件对话框
- local file = win.saveDlg("保存图片","*.jpg|*.jpg|*.bmp|*.bmp|*.png|*.png||",deffile)
- img:save( file );
- ]]>
- </脚本区块>
- <数据区块 />
- </ApeML>
复制代码
[ 本帖最后由 一鹤(hjz) 于 2006-6-9 22:36 编辑 ] |
|