找回密码
 加入
搜索
查看: 6929|回复: 4

[GUI管理] [已解决]请教GUI界面整合HTML代码获取功能后不能正常使用的原因

[复制链接]
发表于 2014-7-28 22:31:46 | 显示全部楼层 |阅读模式
本帖最后由 riskstar 于 2014-7-29 07:50 编辑

最近想写一个根据URL地址自动抽取对应的HTML页面的标题和内容的小工具,用于转帖。单独的GUI框架和HTML代码获取部分独立运行都没有问题,但是整合在一起就出现问题,烦请大家帮忙指点一下原因,谢谢!

示例地址:http://www.acfun.tv/a/ac1308779
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#Region ### START Koda GUI section ### Form=c:\source\gui\acfun文章获取.kxf
$Form1_1 = GUICreate("ACFUN文章获取器", 637, 456, 192, 124)
$Label1 = GUICtrlCreateLabel("URL地址:", 40, 16, 100, 29)
GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
$Input1 = GUICtrlCreateInput("", 144, 16, 425, 21)
$Edit1 = GUICtrlCreateEdit("", 40, 104, 529, 281)
;GUICtrlSetData(-1, "")
GUICtrlSetData($Edit1, "")
$Button1 = GUICtrlCreateButton("抓取", 56, 400, 75, 25)
$Button2 = GUICtrlCreateButton("复制标题", 448, 400, 75, 25)
$Button3 = GUICtrlCreateButton("复制内容", 192, 400, 75, 25)
$Button4 = GUICtrlCreateButton("清空", 320, 400, 75, 25)
$Label2 = GUICtrlCreateLabel("文章标题:", 40, 56, 100, 33)
GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
$Input2 = GUICtrlCreateInput("", 144, 56, 425, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $nMsg = $Button1
                        $Url= GUICtrlRead($Input1)
                        Local $InetRead = InetRead($Url),  $HTMLContents
                        If $InetRead <> "" Then $HTMLContents = BinaryToString($InetRead, 4)
                        $_Title = _StringBetween($HTMLContents, '<h2>', '</h2>')
                        $_Content= _StringBetween($HTMLContents, '<span class="clearfix"></span></div><div id="area-player"><p>', '<span class="clearfix"></span></div>')
                        GUICtrlSetData($Input2 , $_Title[0])
                        GUICtrlSetData($Edit1 , $_Content[0]) 
                Case $nMsg = $Button2        
                        $_Title = GUICtrlRead($Input2)
                Case $nMsg = $Button3        
                        $_Title = GUICtrlRead($Edit1)
                Case $nMsg = $Button4        
                        GUICtrlSetData($Input1, "")
                        GUICtrlSetData($Input2, "")
                        GUICtrlSetData($Edit1, "")
        EndSwitch                
WEnd

本帖子中包含更多资源

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

×
发表于 2014-7-29 05:57:08 | 显示全部楼层

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#Region ### START Koda GUI section ### Form=c:\source\gui\acfun文章获取.kxf
$Form1_1 = GUICreate("ACFUN文章获取器", 637, 456, 192, 124)
$Label1 = GUICtrlCreateLabel("URL地址:", 40, 16, 100, 29)
GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
$Input1 = GUICtrlCreateInput("", 144, 16, 425, 21)
$Edit1 = GUICtrlCreateEdit("", 40, 104, 529, 281)
;GUICtrlSetData(-1, "")
GUICtrlSetData($Edit1, "")
$Button1 = GUICtrlCreateButton("抓取", 56, 400, 75, 25)
$Button2 = GUICtrlCreateButton("复制标题", 448, 400, 75, 25)
$Button3 = GUICtrlCreateButton("复制内容", 192, 400, 75, 25)
$Button4 = GUICtrlCreateButton("清空", 320, 400, 75, 25)
$Label2 = GUICtrlCreateLabel("文章标题:", 40, 56, 100, 33)
GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
$Input2 = GUICtrlCreateInput("", 144, 56, 425, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $Url= GUICtrlRead($Input1)
                        Local $InetRead = InetRead($Url),  $HTMLContents
                        If $InetRead <> "" Then $HTMLContents = BinaryToString($InetRead, 4)
                        $_Title = _StringBetween($HTMLContents, '<h2>', '</h2>')
                        $_Content= _StringBetween($HTMLContents, '<span class="clearfix"></span></div><div id="area-player"><p>', '<span class="clearfix"></span></div>')
                        GUICtrlSetData($Input2 , $_Title[0])
                        GUICtrlSetData($Edit1 , $_Content[0]) 
                Case $Button2        
                        $_Title = GUICtrlRead($Input2)
                Case $Button3        
                        $_Title = GUICtrlRead($Edit1)
                Case $Button4        
                        GUICtrlSetData($Input1, "")
                        GUICtrlSetData($Input2, "")
                        GUICtrlSetData($Edit1, "")
        EndSwitch                
WEnd
 楼主| 发表于 2014-7-29 07:51:07 | 显示全部楼层
回复 2# nmgwddj


    谢谢
发表于 2014-7-29 07:54:09 | 显示全部楼层
谢谢。。。学习力
发表于 2014-7-29 18:26:57 | 显示全部楼层
学习,学习,感谢感谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 15:37 , Processed in 0.099807 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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