|
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinHttp_GetRespond.au3>
#include <_Ini.au3>
#include <Array.au3>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Form1 = GUICreate("诗词搜索", 443, 466, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 5, 5, 431, 366)
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("下一条", 354,376,75,25)
$Button2 = GUICtrlCreateButton("查找", 354, 406, 75, 25)
$Button3 = GUICtrlCreateButton("写入文本",354, 436, 75, 25)
$Label1 = GUICtrlCreateLabel("题目",10,380,45,25)
$Input1 = GUICtrlCreateInput("",45,376,130,25);诗词题目
$Label2 = GUICtrlCreateLabel("作者",200,380,45,25)
$Input2 = GUICtrlCreateInput("",230,376,80,25);作者
GUISetState(@SW_SHOW)
Global $i=0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$i=$i+1
GUICtrlSetData($Edit1, '')
;GUICtrlSetData($Edit1,$i)
$shi_t=_IniRead(@ScriptDir& "\cd1.ini","shi",$i)
Local $Test = StringRegExp($shi_t, '(.+?)-(.++)', 3)
GUICtrlSetData($Input1,$Test[1])
GUICtrlSetData($Input2,$Test[0])
Case $Button2
$timuz = GUICtrlRead($Input1);读取题目
$timuz= AnsiURLEncode($timuz,0) ;转为url编码
$timuUrl ="http://gushi.qinqishuhua.org/more.php?keyWord="&$timuz&"&type=bt&imageField.x=23&imageField.y=14"
MsgBox(0,"ok",$timuUrl)
Local $cookie ="cck_lasttime=1331731504515; cck_count=1; Hm_lvt_e7ab7ade59ef1a4e32ebe66571f240df=1331731507718; Hm_lpvt_e7ab7ade59ef1a4e32ebe66571f240df=1331731507718"
$rContext=_WinHTTP_GetRespond(-1,$timuUrl,2+4+64,5000,-1,$cookie)
;Local $Test = StringRegExp($rContext[0],'</A><SPAN class=more><A href="(.+?)"',3)
;_ArrayDisplay($Test, UBound($Test))
;$rContext2=_WinHTTP_GetRespond(-1,"http://gushi.qinqishuhua.org"&$Test,2)
;MsgBox(0,"dizhi",$rContext2[0])
;Local $Test2 = StringRegExp($rContext2[0],'META content="(.+?)"',3)
;_ArrayDisplay($Test2, UBound($Test2))
;GUICtrlSetData($Edit1,$Test)
Case $Button3
FileWrite ( @DesktopDir & "\诗词.txt" , GUICtrlRead($Input1))
FileWrite ( @DesktopDir & "\诗词.txt" , GUICtrlRead($Input2))
FileWrite ( @DesktopDir & "\诗词.txt" , GUICtrlRead($Edit1))
EndSwitch
WEnd
Func AnsiURLEncode($str, $falg = 0)
;转换字符串为ANSI(GB2312)URL编码By afan
;可选参数$falg = 0,不转换字母及数字(默认);$falg = 1,全部转换(字符头http://除外)
Local $str_s = StringRegExpReplace($str, '^(http://).+', '$1')
If @extended = 0 Then $str_s = ''
If @extended > 0 Then $str = StringRegExpReplace($str, '^http://', '')
Local $astr, $i, $s2d, $sS = StringSplit($str, '')
For $i = 1 To UBound($sS) - 1
If StringRegExp($sS[$i], '[^\x00-\xff]') Then
$s2d = StringToBinary($sS[$i] & ' ')
$astr &= '%' & StringMid($s2d, 3, 2) & '%' & StringMid($s2d, 5, 2)
ElseIf StringRegExp($sS[$i], '[^\w]') Then
$s2d = StringToBinary($sS[$i])
$astr &= '%' & StringMid($s2d, 3, 2)
Else
If $falg = 0 Then $astr &= $sS[$i]
If $falg <> 0 Then
$s2d = StringToBinary($sS[$i])
$astr &= '%' & StringMid($s2d, 3, 2)
EndIf
EndIf
Next
$astr = StringReplace($astr, '%20', '+') ;转换空格的编码为'+'号,也可不要此行
Return $str_s & $astr
EndFunc ;==>AnsiURLEncode
cd.ini
[shi]
1=张九龄-感遇 四首
2=李白-下终南山过斛斯山人宿置酒
3=李白-月下独酌
4=李白-春思
5=杜甫-望岳
6=杜甫-赠卫八处上
7=杜甫-佳人
8=杜甫-梦李白 二首
9=王维-送别
10=王维-送綦毋潜落第还乡
11=王维-青溪
12=王维-渭川田家
13=王维-西施咏
14=孟浩然-秋登万山寄张五
15=孟浩然-夏日南亭怀辛大
16=孟浩然-宿业师山房待丁大不至
17=王昌龄-同从弟南斋玩月忆山阴崔少府
18=丘为-寻西山隐者不遇
19=綦毋潜-春泛若耶溪
20=常建-宿王昌龄隐居
21=岑参-与高适薛据登慈恩寺浮图
22=元结-贼退示官吏
23=韦应物-郡斋雨中与诸文士燕集
24=韦应物-初发扬子寄元大校书
25=韦应物-寄全椒山中道士
26=韦应物-长安遇冯著
27=韦应物-夕次盱眙县
28=韦应物-东郊
29=韦应物-送杨氏女
30=柳宗元-晨诣超师院读禅经
31=柳宗元-溪居
32=王昌龄-塞上曲
33=王昌龄-塞下曲
34=李白-关山月
35=李白-子夜吴歌 一首
36=李白-长干行
37=孟郊-烈女操
38=孟郊-游子吟
从msgbox中看到地址是没有问题的,但是从发送拦截到地址看诗词的标题只能显示一个汉字,还不一定是标题中的一个字 |
|