找回密码
 加入
搜索
查看: 2474|回复: 5

[IE类操作] 提取网站内容乱码问题

  [复制链接]
发表于 2011-6-16 17:57:08 | 显示全部楼层 |阅读模式
我想读取http://baidu.lehecai.com/lottery ... 1&de=2011-06-15中的源码,从中提取如图这样的数据来保存起来,供学习之用。

为什么以下代码在msgbox中正常,而写入到文本后好多是乱码,请教如何设置呢?
代码如下:
#include <INet.au3>
$http = 'http://baidu.lehecai.com/lottery/draw/list/50?lottery_type=50&page=1&ds=2011-01-01&de=2011-06-15' 
$sData = InetRead($http)

;$sData = _INetGetSource($http)

$Source = BinaryToString($sData, 4)
MsgBox(0, 0, $Source)
ClipPut($Source)
$ym=ClipGet()
FileWrite("01.txt",$ym)

本帖子中包含更多资源

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

×
发表于 2011-6-16 18:55:24 | 显示全部楼层
本帖最后由 daiyu116 于 2011-6-16 19:00 编辑

回复 1# m765555
这样试试呢?

#include <INet.au3>
$http = 'http://baidu.lehecai.com/lottery/draw/list/50?lottery_type=50&page=1&ds=2011-01-01&de=2011-06-15'
$sData = InetRead($http)

;$sData = _INetGetSource($http)

$Source = BinaryToString($sData, 4)
MsgBox(0, 0, $Source)
ClipPut($Source)
$ym=ClipGet()
infolog($ym,"c:\1.Log")

;创建记录文件并写入内容
Func infolog($string,$filePath_name)
        $file =FileOpen($filePath_name,137)
        ; 检查打开的文件可写
        If $file = -1 Then
                MsgBox(0, "错误", "不能创建或打开文件"&$filePath_name&",如无该文件,请手动创建"&$filePath_name&".如无法创建,程序也将继续运行!")
                Return -1
        EndIf
        $writeok=FileWriteLine($filePath_name,$string & @CRLF)
        If $writeok=1 Then
                FileClose($filePath_name)
                Return 1
        Else
                MsgBox(0, "错误","向文件"&$filePath_name&"写入错误,请检查文件是否只读属性!但并不妨碍程序继续运行!")
                Return 0
        EndIf
EndFunc
发表于 2011-6-16 20:11:00 | 显示全部楼层
_INetGetSource就是inrterread和BinaryToString的结合,你这BinaryToString两次,当然会有乱码
 楼主| 发表于 2011-6-17 08:14:15 | 显示全部楼层
二楼的代码同样有乱码,再试试其它
发表于 2011-6-18 21:45:33 | 显示全部楼层
帮你试了试,用ansi方式查看就不会乱码了.
发表于 2011-6-18 21:54:14 | 显示全部楼层
学习了..顶一个
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-12 15:46 , Processed in 0.080835 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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