找回密码
 加入
搜索
查看: 5338|回复: 9

[AU3基础] 请教大大,如何让IECreate获取txt文本里面的网址。

  [复制链接]
发表于 2013-11-17 00:45:30 | 显示全部楼层 |阅读模式
本帖最后由 sky 于 2013-11-17 00:50 编辑
#include <IE.au3>
$oIE = _IECreate ("http://www.aaa.com/post")
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetObjByName ($oForm, "subject")
_IEFormElementSetValue ($oQuery, "aaaaaa");主题
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetObjByName ($oForm, "username")
_IEFormElementSetValue ($oQuery, "22222");用户名
_IEFormSubmit ($oForm)
Sleep(15000)
ProcessClose("iexplorer.exe")

$oIE = _IECreate ("http://www.bbb.com/post")
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetObjByName ($oForm, "subject")
_IEFormElementSetValue ($oQuery, "aaaaaa");主题
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetObjByName ($oForm, "username")
_IEFormElementSetValue ($oQuery, "22222");用户名
_IEFormSubmit ($oForm)
Sleep(15000)
ProcessClose("iexplorer.exe")

$oIE = _IECreate ("http://www.ccc.com/post")
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetObjByName ($oForm, "subject")
_IEFormElementSetValue ($oQuery, "aaaaaa");主题
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetObjByName ($oForm, "username")
_IEFormElementSetValue ($oQuery, "22222");用户名
_IEFormSubmit ($oForm)
Sleep(15000)
ProcessClose("iexplorer.exe")
如上代码,请问高手,如何把那些网址弄到txt文本逐行读取。那可是200多个网址啊。
发表于 2013-11-17 10:12:51 | 显示全部楼层
用这个函数吧,
FileReadLine
--------------------------------------------------------------------------------
从此前已打开的文本文件中读取指定行的字符.
FileReadLine ( "文件句柄/文件名" [, 行号] )
 楼主| 发表于 2013-11-17 10:28:31 | 显示全部楼层
回复 2# netsmu

但是如何自动检测有几行网址,从第一行逐行操作到最后呢?
发表于 2013-11-17 10:45:49 | 显示全部楼层
#Include <File.au3>
$numtxt = _FileCountLines("txt.txt")  ;获取行数
for $i=1 to $numtxt
;这里是你要循环的内容,比如有5行,就循环5次,
;最好做个if 检测获取到的行的数据是否为空,比如
if FileReadLine ("",$i) <> "" then
;获取到行的数据不为空才执行你要的内容。
endif

next
 楼主| 发表于 2013-11-17 17:27:10 | 显示全部楼层
回复 4# netsmu

试了一下,没弄出来。我还是太菜了,有哪位大大帮我写完整?
发表于 2013-11-17 17:44:00 | 显示全部楼层
回复 5# sky
#include <IE.au3>
#Include <File.au3>
$numtxt = _FileCountLines("网址文件.txt")
For $i=1 To $numtxt
        $gettxt = FileReadLine ("网址文件.txt",$i)
        If $gettxt <> "" then
                
                $oIE = _IECreate ($gettxt)
                $oForm = _IEFormGetCollection ($oIE, 0)
                $oQuery = _IEFormElementGetObjByName ($oForm, "subject")
                _IEFormElementSetValue ($oQuery, "aaaaaa");主题
                $oForm = _IEFormGetCollection ($oIE, 0)
                $oQuery = _IEFormElementGetObjByName ($oForm, "username")
                _IEFormElementSetValue ($oQuery, "22222");用户名
                _IEFormSubmit ($oForm)
                Sleep(15000)
                ProcessClose("iexplorer.exe")
        EndIf
Next
这个很简单啊, 自己要多学学了,基本的FOR,IF 的。
 楼主| 发表于 2013-11-17 17:54:44 | 显示全部楼层
回复 6# netsmu

我刚才就是出现这个,现在用了你的代码也是出现这个错误。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2013-11-17 18:12:39 | 显示全部楼层
那是你本身的代码就有问题了。

#include <IE.au3>
$oIE = _IECreate ("http://www.aaa.com/post")
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetObjByName ($oForm, "subject")
_IEFormElementSetValue ($oQuery, "aaaaaa");主题
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetObjByName ($oForm, "username")
_IEFormElementSetValue ($oQuery, "22222");用户名
_IEFormSubmit ($oForm)
Sleep(15000)
ProcessClose("iexplorer.exe")

你自己这个就有问题了,自己解决一下吧。
发表于 2013-11-17 18:14:30 | 显示全部楼层
我这边编译没问题, 编辑器  3361版本。
 楼主| 发表于 2013-11-17 18:19:44 | 显示全部楼层
回复 9# netsmu

好的,你没问题,那应该是版本的问题。我运行自己代码绝对正常。
应该是版本问题,我先检查一下,晚点回报情况,多谢大大!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-28 04:50 , Processed in 0.078816 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表