爬虫源码.au3 18 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126
  1. #include <array.au3>
  2. #include <GUIConstants.au3>
  3. #include<IE.au3>
  4. ;#include<setdefault.au3>
  5. #include<file.au3>
  6. #include <MsgBoxConstants.au3>
  7. #include<excel.au3>
  8. #RequireAdmin
  9. #include<_html.au3>
  10. #include<sfilter.au3>
  11. ;Opt("CaretCoordMode", 1)
  12. ;Opt("ExpandEnvStrings", 0)
  13. Opt("ExpandVarStrings", 0)
  14. ;Opt("GUICloseOnESC", 0)
  15. ;Opt("GUICoordMode", 1)
  16. ;Opt("GUIDataSeparatorChar","|")
  17. ;Opt("GUIOnEventMode", 0)
  18. ;Opt("GUIResizeMode",0)
  19. ;Opt("GUIEventOptions",1)
  20. Opt("MouseClickDelay", 10)
  21. Opt("MouseClickDownDelay", 10)
  22. Opt("MouseClickDragDelay", 250)
  23. Opt("MouseCoordMode", 1)
  24. Opt("MustDeclareVars", 0)
  25. Opt("PixelCoordMode", 1)
  26. Opt("SendAttachMode", 0)
  27. Opt("SendCapslockMode", 1)
  28. Opt("SendKeyDelay", 5)
  29. Opt("SendKeyDownDelay", 1)
  30. Opt("TCPTimeout",100)
  31. Opt("TrayAutoPause",1)
  32. Opt("TrayIconDebug", 0)
  33. Opt("TrayIconHide", 0)
  34. Opt("TrayMenuMode",0)
  35. Opt("TrayOnEventMode",0)
  36. Opt("WinDetectHiddenText", 0)
  37. Opt("WinSearchChildren", 1)
  38. Opt("WinTextMatchMode", 1)
  39. Opt("WinTitleMatchMode", 1)
  40. Opt("WinWaitDelay", 250)
  41. $Form1_1 = GUICreate("Form1", 618, 325, 192, 114)
  42. ConsoleWrite(@ScriptLineNumber&@CRLF)
  43. $Input1 = GUICtrlCreateInput("匹配规则", 56, 32, 433, 21)
  44. ConsoleWrite(@ScriptLineNumber&@CRLF)
  45. $Button1 = GUICtrlCreateButton("选择列表文件", 496, 32, 89, 25)
  46. ConsoleWrite(@ScriptLineNumber&@CRLF)
  47. $List1 = GUICtrlCreateList("", 56, 168, 433, 136)
  48. ConsoleWrite(@ScriptLineNumber&@CRLF)
  49. $Button3 = GUICtrlCreateButton("开始", 392, 136, 97, 33)
  50. ConsoleWrite(@ScriptLineNumber&@CRLF)
  51. $Button4 = GUICtrlCreateButton("选择保存路径", 496, 72, 89, 25)
  52. ConsoleWrite(@ScriptLineNumber&@CRLF)
  53. $Input2 = GUICtrlCreateInput("Input2", 56, 72, 433, 21)
  54. ConsoleWrite(@ScriptLineNumber&@CRLF)
  55. $Combo1 = GUICtrlCreateCombo("Combo1", 64, 144, 193, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
  56. ConsoleWrite(@ScriptLineNumber&@CRLF)
  57. $Label1 = GUICtrlCreateLabel("检查列表", 56, 16, 160, 17)
  58. ConsoleWrite(@ScriptLineNumber&@CRLF)
  59. GUISetState(@SW_SHOW)
  60. #EndRegion ### END Koda GUI section ###While 1
  61. Global $g_idGUIEdit
  62. Global $g_idGUIProg
  63. global $oIE=0
  64. ConsoleWrite(@ScriptLineNumber&@CRLF)
  65. Global $filepath=@scriptdir
  66. ConsoleWrite(@ScriptLineNumber&@CRLF)
  67. Global $size=0 ;difine listfile size
  68. ConsoleWrite(@ScriptLineNumber&@CRLF)
  69. Global $list_file_url=@ScriptDir&"\任务列表.txt";页面提取的文件
  70. ConsoleWrite(@ScriptLineNumber&@CRLF)
  71. Global $line_url="http://guba.eastmoney.com/"
  72. ConsoleWrite(@ScriptLineNumber&@CRLF)
  73. Global $state=""
  74. ConsoleWrite(@ScriptLineNumber&@CRLF)
  75. Global $stock_id=""
  76. ConsoleWrite(@ScriptLineNumber&@CRLF)
  77. Global $resault_dir=@scriptdir&"\data"
  78. ConsoleWrite(@ScriptLineNumber&@CRLF)
  79. Global $excel_file=@scriptdir&"\采集内容.xls"
  80. ConsoleWrite(@ScriptLineNumber&@CRLF)
  81. Global $oEventObject
  82. GLOBAL $SIZES=0
  83. ConsoleWrite(@ScriptLineNumber&@CRLF)
  84. GLOBAL $CURPID=0
  85. ConsoleWrite(@ScriptLineNumber&@CRLF)
  86. global $TXTDATA=""
  87. ConsoleWrite(@ScriptLineNumber&@CRLF)
  88. Global $oExcel, $oWorkbook
  89. Global $cur_process=0
  90. ConsoleWrite(@ScriptLineNumber&@CRLF)
  91. While 1
  92. ;GUISetState(@SW_SHOW)
  93. $mainui_nMsg = GUIGetMsg()
  94. ConsoleWrite(@ScriptLineNumber&@CRLF)
  95. Switch $mainui_nMsg
  96. ;Case $GUI_EVENT_CLOSE
  97. ; Exit
  98. case $button1
  99. Global $size=_FileCountLines ($list_file_url)
  100. ConsoleWrite(@ScriptLineNumber&@CRLF)
  101. GLOBAL $iCountLines = $size
  102. ConsoleWrite(@ScriptLineNumber&@CRLF)
  103. if $size >0 then
  104. MsgBox($MB_SYSTEMMODAL, "",$list_file_url&" 内有"& $size&"行,可以开始操作")
  105. else
  106. MsgBox($MB_SYSTEMMODAL, "", "没有找到地址列表或者有错,指定 任务列表.txt.")
  107. endif
  108. case $button3
  109. ;选择文件
  110. ;$list_file_url=$resault_dir & "\任务列表.txt"
  111. Global $size=_FileCountLines ($list_file_url)
  112. ConsoleWrite(@ScriptLineNumber&@CRLF)
  113. GLOBAL $iCountLines = $size
  114. ConsoleWrite(@ScriptLineNumber&@CRLF)
  115. if $size >0 then
  116. MsgBox($MB_SYSTEMMODAL, "",$list_file_url&" 内有"& $size&"行,可以开始操作")
  117. else
  118. MsgBox($MB_SYSTEMMODAL, "", "没有找到地址列表或者有错,指定 任务列表.txt.")
  119. endif
  120. ;加载列表d
  121. Local $aRetArray[1] = [0]
  122. ConsoleWrite(@ScriptLineNumber&@CRLF)
  123. _FileReadToArray($list_file_url, $aRetArray, $FRTA_NOCOUNT, ",")
  124. GUICtrlSetData($List1,$aRetArray)
  125. ConsoleWrite("开始工作")
  126. case $button4 ;选择保存路径
  127. $resault_dir=FileSelectFolder("选择要保存的路径", @ScriptDir)
  128. ConsoleWrite(@ScriptLineNumber&@CRLF)
  129. GUICtrlSetData($Input2,$resault_dir)
  130. If @error Then
  131. ; 显示发生错误消息.
  132. MsgBox($MB_SYSTEMMODAL, "", "没有选择任何文件夹.")
  133. else
  134. MsgBox($MB_SYSTEMMODAL, "", $resault_dir)
  135. ;开始载入IE
  136. start_job($oIE);执行打开窗口
  137. endif;关闭选择文件循环
  138. EndSwitch;界面选择事件结束
  139. _Excel_BookSave($oWorkbook)
  140. WEnd
  141. ;结束gui事件
  142. removeIE()
  143. Func start_job($oie)
  144. ;进程包括了IE窗口生成
  145. Local $iMsg
  146. local $hGUIMain
  147. $hGUIMain = GUICreate("IE BROWSER", 600, 500)
  148. ConsoleWrite(@ScriptLineNumber&@CRLF)
  149. $g_idGUIEdit = GUICtrlCreateEdit("626" & @CRLF, 10, 20, 580, 400)
  150. ConsoleWrite(@ScriptLineNumber&@CRLF)
  151. $g_idGUIProg = GUICtrlCreateProgress(10, 5, 580, 10)
  152. ConsoleWrite(@ScriptLineNumber&@CRLF)
  153. Local $idGUIExit = GUICtrlCreateButton("退出采集", 250, 450, 80, 30)
  154. ConsoleWrite(@ScriptLineNumber&@CRLF)
  155. GUISetState() ;Show GUI
  156. Sleep(1000) ; Give it some time to load the web page
  157. GUISwitch($hGUIMain) ; Switch back to our GUI in case IE stole the focus
  158. ; We prepare the Internet Explorer as our test subject
  159. ieobjint()
  160. While 1
  161. $iMsg = GUIGetMsg()
  162. ConsoleWrite(@ScriptLineNumber&@CRLF)
  163. If $iMsg = $idGUIExit Then exit
  164. ConsoleWrite(@ScriptLineNumber&@CRLF)
  165. DOWN_BY_LIST($list_file_url)
  166. ;按列表下载
  167. WEnd
  168. EndFunc ;==>Example
  169. Func DOWN_BY_LIST($list_file_url)
  170. MsgBox($MB_SYSTEMMODAL, "", "开始下载列表里网址.")
  171. $FILE_HWN=FileOpen($list_file_url,1)
  172. ConsoleWrite(@ScriptLineNumber&@CRLF)
  173. $size=_FileCountLines($list_file_url)
  174. ConsoleWrite(@ScriptLineNumber&@CRLF)
  175. If $list_file_url = "" Then
  176. ConsoleWrite(@ScriptLineNumber&@CRLF)
  177. MsgBox($MB_SYSTEMMODAL, "", "没有选择入口列表.现在退回")
  178. Return
  179. else
  180. MsgBox($MB_SYSTEMMODAL, "", "程序会删除访问过的列表行,如没有备份,现在可以先备份原始列表,否则继续。")
  181. EndIf
  182. for $SIZES=$size to 1 Step -1
  183. ConsoleWrite(@ScriptLineNumber&@CRLF)
  184. ;
  185. $state=""
  186. ConsoleWrite(@ScriptLineNumber&@CRLF)
  187. $line_url = FileReadLine($list_file_url,$SIZES)
  188. ConsoleWrite(@ScriptLineNumber&@CRLF)
  189. fileclose($line_url)
  190. ConsoleWrite("列表名称"&$line_url)
  191. If StringLen($line_url)>10 Then
  192. ;to be continue
  193. $stock_id=StringTrimRight(StringTrimLeft( "$line_url",38 ),5)
  194. ConsoleWrite(@ScriptLineNumber&@CRLF)
  195. $oIE.navigate($line_url)
  196. _ieloadwait($oIE)
  197. sleep(500)
  198. ConsoleWrite($LINE_URL&@CRLF)
  199. GLOBAL $CURPID=1
  200. ConsoleWrite(@ScriptLineNumber&@CRLF)
  201. pagereconize()
  202. set_stock_show()
  203. ;ending
  204. SetError(0)
  205. EndIf
  206. ;=========================================================
  207. _FileWriteToLine($list_file_url,$SIZES,"",True)
  208. fileclose($line_url)
  209. ;
  210. Next
  211. MsgBox($MB_SYSTEMMODAL, "", "已经提取完网址,右下任务栏选退出.")
  212. ;FileClose($FILE_HWN)
  213. EXIT
  214. ENDFUNC
  215. ;=================================================
  216. Func IEEvent_BeforeNavigate($line_url, $iFlags, $sTargetFrameName, $dPostData, $sHeaders, $bCancel)
  217. ; Note: the declaration is different from the one on MSDN.
  218. GUICtrlSetData($g_idGUIEdit, "BeforeNavigate: ")
  219. SetError(0)
  220. EndFunc ;==>IEEvent_BeforeNavigate
  221. ;=================================================
  222. Func IEEvent_ProgressChange($iProgress, $iProgressMax)
  223. If $iProgressMax > 0 Then
  224. GUICtrlSetData($g_idGUIProg, ($iProgress * 100) / $iProgressMax)
  225. EndIf
  226. SetError(0)
  227. EndFunc ;==>IEEvent_ProgressChange
  228. Func IEEvent_StatusTextChange($sText)
  229. GUICtrlSetData($g_idGUIEdit, $sText)
  230. SetError(0)
  231. EndFunc ;==>IEEvent_StatusTextChange
  232. ;=================================================
  233. Func IEEvent_PropertyChange($szProperty)
  234. SetError(0)
  235. GUICtrlSetData($g_idGUIEdit, "IE Changed the value of the property: " & $szProperty & @CRLF)
  236. EndFunc ;==>IEEvent_PropertyChange
  237. ;=================================================
  238. Func IEEvent_DownloadComplete()
  239. GUICtrlSetData($g_idGUIEdit, "IE has finished a navigation operation" & @CRLF)
  240. SetError(0)
  241. EndFunc ;==>IEEvent_DownloadComplete
  242. ;=================================================浏览器下载完识别=====================================
  243. Func IEEvent_NavigateComplete($line_url)
  244. ; Note: the declaration is different from the one on MSDN.
  245. GUICtrlSetData($g_idGUIEdit, $line_url)
  246. Switch $CURPID
  247. CASE 1
  248. pagereconize()
  249. EndSwitch
  250. SetError(0)
  251. EndFunc ;==>IEEvent_NavigateComplete
  252. Func IEEvent_($sEventName)
  253. SetError(0)
  254. ieobjint()
  255. seterror(0)
  256. GUICtrlSetData($g_idGUIEdit, "Uncatched event: " & $sEventName & @CRLF )
  257. EndFunc ;==>IEEvent_
  258. ;======================================================================================
  259. Func download_event($state)
  260. SetError(0)
  261. GUICtrlSetData($g_idGUIEdit, "Uncatched event: " & $state & @CRLF)
  262. EndFunc
  263. ;=================================================出错重置====================================
  264. Func _ErrFunc($oError)
  265. ieobjint()
  266. seterror(0)
  267. EndFunc ;==>_ErrFunc
  268. ;=================================================浏====================================
  269. ;=================================================浏览器参数设置=====================================
  270. func ieobjint()
  271. global $oIE=0
  272. ConsoleWrite(@ScriptLineNumber&@CRLF)
  273. _IELoadWaitTimeout(1500)
  274. $oIE = ObjCreate("InternetExplorer.Application.1")
  275. ConsoleWrite(@ScriptLineNumber&@CRLF)
  276. $oIE.Navigate("http://baidu.com")
  277. $sURL = "http://guba.eastmoney.com/list,600382.html"
  278. ConsoleWrite(@ScriptLineNumber&@CRLF)
  279. Local $oEventObject = ObjEvent($oIE, "IEEvent_", "DWebBrowserEvents")
  280. ConsoleWrite(@ScriptLineNumber&@CRLF)
  281. If @error Then
  282. MsgBox($MB_OK, "有错误发生", _
  283. "ObjEvent: Can't use event interface 'DWebBrowserEvents'. Error code: " & Hex(@error, 8))
  284. EndIf
  285. With $oIE
  286. .Visible = 1
  287. .Top = (@DesktopHeight - 400) / 2
  288. .Height = 400 ; Make it a bit smaller than our GUI.
  289. .Width = 600
  290. .Silent = 1 ; Don't show IE's dialog boxes
  291. GLOBAL $hIEWnd = HWnd(.hWnd) ; Remember the Window, in case user decides to close it
  292. ConsoleWrite(@ScriptLineNumber&@CRLF)
  293. EndWith
  294. endfunc
  295. ;=================================================浏览器参数设置=====================================
  296. func removeIE()
  297. $oEventObject.Stop ; Tell IE we don't want to receive events.
  298. $oEventObject = 0 ; Kill the Event Object
  299. ConsoleWrite(@ScriptLineNumber&@CRLF)
  300. If WinExists($hIEWnd) Then $oIE.Quit ; Close IE Window
  301. $oIE = 0 ; Remove IE from memory (not really necessary).
  302. ConsoleWrite(@ScriptLineNumber&@CRLF)
  303. ;GUIDelete($hGUIMain) ; Remove GUI
  304. endfunc
  305. func set_stock_show()
  306. GUICtrlSetData($input1,$stock_id)
  307. endfunc
  308. func pagereconize()
  309. Local $Ele = @extended
  310. ConsoleWrite(@ScriptLineNumber&@CRLF)
  311. ;local $data=@extended
  312. SLEEP(1000)
  313. ;=====================数量============================
  314. SLEEP(300)
  315. Local $tags= @extended
  316. ConsoleWrite(@ScriptLineNumber&@CRLF)
  317. $tags = $oIE.document.GetElementsByTagName("div")
  318. ConsoleWrite(@ScriptLineNumber&@CRLF)
  319. Local $text_s=""
  320. ConsoleWrite(@ScriptLineNumber&@CRLF)
  321. Local $tmp=""
  322. ConsoleWrite(@ScriptLineNumber&@CRLF)
  323. For $tag in $tags
  324. ; $class_value = $tag.GetAttribute("class")
  325. $class_value = $tag.className
  326. ConsoleWrite(@ScriptLineNumber&@CRLF)
  327. If $class_value = "zwmbtilr" Then
  328. ConsoleWrite(@ScriptLineNumber&@CRLF)
  329. $tmp=$tag.innertext
  330. ConsoleWrite(@ScriptLineNumber&@CRLF)
  331. $text_s=$tmp&$text_s&@CRLF
  332. ConsoleWrite(@ScriptLineNumber&@CRLF)
  333. EndIf
  334. Next
  335. $TXTDATA=HTML_Filter($text_s,0)
  336. ConsoleWrite(@ScriptLineNumber&@CRLF)
  337. FileWriteLine(@scriptdir&"\data.txt",$TXTDATA&"/////")
  338. consolewrite($TXTDATA&@CRLF)
  339. ;================================================================E
  340. LOCAL $TXTDATA="";3数
  341. ConsoleWrite(@ScriptLineNumber&@CRLF)
  342. ;=======================时间==========================
  343. SLEEP(300)
  344. SLEEP(300)
  345. Local $tags= @extended
  346. ConsoleWrite(@ScriptLineNumber&@CRLF)
  347. $tags = $oIE.document.GetElementsByTagName("DIV")
  348. ConsoleWrite(@ScriptLineNumber&@CRLF)
  349. Local $text_s=""
  350. ConsoleWrite(@ScriptLineNumber&@CRLF)
  351. Local $tmp=""
  352. ConsoleWrite(@ScriptLineNumber&@CRLF)
  353. For $tag in $tags
  354. ; $class_value = $tag.GetAttribute("class")
  355. $class_value = $tag.className
  356. ConsoleWrite(@ScriptLineNumber&@CRLF)
  357. If $class_value = "zwfbtime" Then
  358. ConsoleWrite(@ScriptLineNumber&@CRLF)
  359. $tmp=$tag.innertext
  360. ConsoleWrite(@ScriptLineNumber&@CRLF)
  361. $text_s=$tmp&$text_s&@CRLF
  362. ConsoleWrite(@ScriptLineNumber&@CRLF)
  363. EndIf
  364. Next
  365. $TXTDATA=HTML_Filter($text_s,0)
  366. ConsoleWrite(@ScriptLineNumber&@CRLF)
  367. FileWriteLine(@scriptdir&"\data.txt",$TXTDATA&"/////")
  368. consolewrite($TXTDATA&@CRLF)
  369. ;================================================================C
  370. LOCAL $TXTDATA=""
  371. ConsoleWrite(@ScriptLineNumber&@CRLF)
  372. ;======================阅读===========================
  373. SLEEP(300)
  374. Local $tags= @extended
  375. ConsoleWrite(@ScriptLineNumber&@CRLF)
  376. $tags = $oIE.document.GetElementsByTagName("SPAN")
  377. ConsoleWrite(@ScriptLineNumber&@CRLF)
  378. Local $text_s=""
  379. ConsoleWrite(@ScriptLineNumber&@CRLF)
  380. Local $tmp=""
  381. ConsoleWrite(@ScriptLineNumber&@CRLF)
  382. For $tag in $tags
  383. ; $class_value = $tag.GetAttribute("class")
  384. $class_value = $tag.className
  385. ConsoleWrite(@ScriptLineNumber&@CRLF)
  386. If $class_value = "tc1" Then
  387. ConsoleWrite(@ScriptLineNumber&@CRLF)
  388. $tmp=$tag.innertext
  389. ConsoleWrite(@ScriptLineNumber&@CRLF)
  390. $text_s=$tmp&$text_s&@CRLF
  391. ConsoleWrite(@ScriptLineNumber&@CRLF)
  392. EndIf
  393. Next
  394. $TXTDATA=HTML_Filter($text_s,0)
  395. ConsoleWrite(@ScriptLineNumber&@CRLF)
  396. FileWriteLine(@scriptdir&"\data.txt",$TXTDATA&"/////")
  397. consolewrite($TXTDATA&@CRLF)
  398. ;================================================================H
  399. LOCAL $TXTDATA=""
  400. ConsoleWrite(@ScriptLineNumber&@CRLF)
  401. ;========================标题=========================
  402. SLEEP(300)
  403. SLEEP(300)
  404. Local $tags= @extended
  405. ConsoleWrite(@ScriptLineNumber&@CRLF)
  406. $tags = $oIE.document.GetElementsByTagName("DIV")
  407. ConsoleWrite(@ScriptLineNumber&@CRLF)
  408. Local $text_s=""
  409. ConsoleWrite(@ScriptLineNumber&@CRLF)
  410. Local $tmp=""
  411. ConsoleWrite(@ScriptLineNumber&@CRLF)
  412. For $tag in $tags
  413. ; $class_value = $tag.GetAttribute("class")
  414. $class_value = $tag.className
  415. ConsoleWrite(@ScriptLineNumber&@CRLF)
  416. If $class_value = "zwconttbt" Then
  417. ConsoleWrite(@ScriptLineNumber&@CRLF)
  418. $tmp=$tag.innertext
  419. ConsoleWrite(@ScriptLineNumber&@CRLF)
  420. $text_s=$tmp&$text_s&@CRLF
  421. ConsoleWrite(@ScriptLineNumber&@CRLF)
  422. EndIf
  423. Next
  424. $TXTDATA=HTML_Filter($text_s,0)
  425. ConsoleWrite(@ScriptLineNumber&@CRLF)
  426. FileWriteLine(@scriptdir&"\data.txt",$TXTDATA&"/////")
  427. consolewrite($TXTDATA&@CRLF)
  428. ;================================================================B
  429. LOCAL $TXTDATA=""
  430. ConsoleWrite(@ScriptLineNumber&@CRLF)
  431. ;====================正文=============================
  432. SLEEP(300)
  433. SLEEP(300)
  434. Local $tags= @extended
  435. ConsoleWrite(@ScriptLineNumber&@CRLF)
  436. $tags = $oIE.document.GetElementsByTagName("SPAN")
  437. ConsoleWrite(@ScriptLineNumber&@CRLF)
  438. Local $text_s=""
  439. ConsoleWrite(@ScriptLineNumber&@CRLF)
  440. Local $tmp=""
  441. ConsoleWrite(@ScriptLineNumber&@CRLF)
  442. For $tag in $tags
  443. ; $class_value = $tag.GetAttribute("class")
  444. $class_value = $tag.className
  445. ConsoleWrite(@ScriptLineNumber&@CRLF)
  446. If $class_value = "zwconbody" Then
  447. ConsoleWrite(@ScriptLineNumber&@CRLF)
  448. $tmp=$tag.innertext
  449. ConsoleWrite(@ScriptLineNumber&@CRLF)
  450. $text_s=$tmp&$text_s&@CRLF
  451. ConsoleWrite(@ScriptLineNumber&@CRLF)
  452. EndIf
  453. Next
  454. $TXTDATA=HTML_Filter($text_s,0)
  455. ConsoleWrite(@ScriptLineNumber&@CRLF)
  456. FileWriteLine(@scriptdir&"\data.txt",$TXTDATA&"/////")
  457. consolewrite($TXTDATA&@CRLF)
  458. ;================================================================D
  459. LOCAL $TXTDATA=""
  460. ConsoleWrite(@ScriptLineNumber&@CRLF)
  461. Local $oLinks = @extended
  462. ConsoleWrite(@ScriptLineNumber&@CRLF)
  463. $oLinks = _IELinkGetCollection($oIE)
  464. ConsoleWrite(@ScriptLineNumber&@CRLF)
  465. Sleep(100)
  466. SetError(0)
  467. Local $curfilename3 =@scriptdir&"\pagereconize.tmp"
  468. ConsoleWrite(@ScriptLineNumber&@CRLF)
  469. FileDelete($curfilename3)
  470. SetError(0)
  471. Local $iNumLinks = @extended
  472. ConsoleWrite(@ScriptLineNumber&@CRLF)
  473. Local $succed = _FileCreate($curfilename3)
  474. ConsoleWrite(@ScriptLineNumber&@CRLF)
  475. SetError(0)
  476. If $succed = 1 Then
  477. ConsoleWrite(@ScriptLineNumber&@CRLF)
  478. FileOpen($curfilename3, $FO_APPEND)
  479. For $oLink In $oLinks
  480. $sTxt = $oLink.href & @CRLF
  481. ConsoleWrite(@ScriptLineNumber&@CRLF)
  482. If StringInStr($stxt, "html#storeply") =1 And StringInStr($stxt,"news,"&$stock_id)=1 Then
  483. ConsoleWrite(@ScriptLineNumber&@CRLF)
  484. FileWrite($curfilename3, $stxt)
  485. EndIf ; 符合适配才使用
  486. ;结束保存搜索结果
  487. Next
  488. EndIf ;succed==1保存结果
  489. FileClose($curfilename3)
  490. SetError(0)
  491. $reply_size=_filecountlines($curfilename3)
  492. ConsoleWrite(@ScriptLineNumber&@CRLF)
  493. ;MsgBox($MB_SYSTEMMODAL, "", $reply_size)
  494. for $rpt=1 to $reply_size
  495. ConsoleWrite(@ScriptLineNumber&@CRLF)
  496. $rpt_line=StringTrimRight($line_url, 5)&"_"&$rpt&".html"
  497. ConsoleWrite(@ScriptLineNumber&@CRLF)
  498. _IENavigate($oie,$rpt_line)
  499. SLEEP(1000)
  500. ;=======================合并回复==========================
  501. SLEEP(300)
  502. SLEEP(300)
  503. Local $tags= @extended
  504. ConsoleWrite(@ScriptLineNumber&@CRLF)
  505. $tags = $oIE.document.GetElementsByTagName("DIV")
  506. ConsoleWrite(@ScriptLineNumber&@CRLF)
  507. Local $text_s=""
  508. ConsoleWrite(@ScriptLineNumber&@CRLF)
  509. Local $tmp=""
  510. ConsoleWrite(@ScriptLineNumber&@CRLF)
  511. For $tag in $tags
  512. ; $class_value = $tag.GetAttribute("class")
  513. $class_value = $tag.className
  514. ConsoleWrite(@ScriptLineNumber&@CRLF)
  515. If $class_value = "zwlitext stockcodec" Then
  516. ConsoleWrite(@ScriptLineNumber&@CRLF)
  517. $tmp=$tag.innertext
  518. ConsoleWrite(@ScriptLineNumber&@CRLF)
  519. $text_s=$tmp&$text_s&@CRLF
  520. ConsoleWrite(@ScriptLineNumber&@CRLF)
  521. EndIf
  522. Next
  523. $TXTDATA=HTML_Filter($text_s,0)
  524. ConsoleWrite(@ScriptLineNumber&@CRLF)
  525. FileWriteLine(@scriptdir&"\data.txt",$TXTDATA&"/////")
  526. consolewrite($TXTDATA&@CRLF)
  527. ;================================================================F
  528. LOCAL $TXTDATA=""
  529. ConsoleWrite(@ScriptLineNumber&@CRLF)
  530. $data=""
  531. ConsoleWrite(@ScriptLineNumber&@CRLF)
  532. ;===============================================
  533. next
  534. $curpid=0
  535. ConsoleWrite(@ScriptLineNumber&@CRLF)
  536. endfunc