sleep365 Posted November 13, 2012 Posted November 13, 2012 (edited) I am in china. The result is unrecognizable .#include <FF.au3>Local $wait_seconds = 3Local $sssIf _FFConnect() Then_FFOpenURL('http://www.baidu.com/') $sss=_FFReadtext(8)MsgBox(0,"",$sss)EndIfExit=========================================the text is what i want get搜索设置|登录注册新 闻 网 页 贴 吧 知 道 音 乐 图 片 视 频 地 图百科 文库 hao123 | 更多>>把百度设为主页把百度添加到桌面加入百度推广 | 搜索风云榜 | 关于百度 | About Baidu©2012 Baidu 使用百度前必读 京ICP证030173号 Attached Thumbnails Edited November 13, 2012 by sleep365
Danp2 Posted November 13, 2012 Posted November 13, 2012 It appears that the return value is being converted and stored in hexidecimal because initial character returned is outside of the standard ASCII character range. Latest Webdriver UDF Release Webdriver Wiki FAQs
mihaibr Posted November 13, 2012 Posted November 13, 2012 (edited) Use BinaryToString() But why you use firefox UDF? you can do this using IE too. #include <IE.au3> Local $oIE = _IECreate("http://www.baidu.com/",0,0) Local $sText = _IEBodyReadText($oIE) MsgBox(0, "Body Text", $sText) Edited November 13, 2012 by mihaibr
jchd Posted November 14, 2012 Posted November 14, 2012 (edited) It appears that the return value is being converted and stored in hexidecimal because initial character returned is outside of the standard ASCII character range.Definitely untrue at any rate.@OP,Check which encoding option works for you. I'm not sure but the binary string you posted "smells" like BIG5 or another 8-bit multibyte encoding (not UTF-8 for sure). You may have to convert the string to UTF-16 (what AutoIt uses) but that depends on your use case and user settings. Edited November 14, 2012 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
sleep365 Posted November 14, 2012 Author Posted November 14, 2012 Thank you all ! I am a newer fo Autoit .i just use autoit develop on firefox ,so i must to use Firefox not IE. The all functon in FF.au3 is not work well when the web has chinese text,
Danp2 Posted November 14, 2012 Posted November 14, 2012 @jchd, Care to elaborate about which part was incorrect? Was it my misuse of hexidecimal? Or what? @sleep365, You can achieve part of your goal by only returning a portion of the text. Local $sRetVal = _FFCmd(".documentElement.textContent.slice(10,3000);", 10000) If Not @error And $sRetVal <> "_FFCmd_Err" Then $sRetVal = __FFFilterString($sRetVal, 8) MsgBox(0,"",$sRetVal) EndIf Latest Webdriver UDF Release Webdriver Wiki FAQs
jchd Posted November 14, 2012 Posted November 14, 2012 @DanP2 Where did you get that _FFReadText ever returned a binary string iff the first character was > 127? Where do you see in the binary shown that the first character (0x22) is outside ASCII range (i.e. > 127)? This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Danp2 Posted November 14, 2012 Posted November 14, 2012 @jchd Actually, I was referring to characters in the lower range (below 32). I don't have much experience with DBCS or multi-byte encoding. I made my initial observation based upon my findings of using Putty to connect to Mozrepl and executing the commands manually. If you replace the call to _FFReadText with the code I posted earlier today, you will see that the returned string is no longer in the form of a binary string, which leads me to believe that one of the initial characters is causing the issue. Latest Webdriver UDF Release Webdriver Wiki FAQs
sleep365 Posted November 15, 2012 Author Posted November 15, 2012 (edited) Drear Danp2: I use you code like that ,the code is well now,but the chinese txt not show very well. why not in _FFReadtext? ,How can i change the _FFReadtext Function? you can right click the mouse to view the web source,and make compare with the $sRetVal ,you will see that chinese text not show very well. Thank you to give me the guide. #include <FF.au3> Local $wait_seconds = 3 Local $sss If _FFConnect() Then _FFOpenURL('http://www.baidu.com/') $sss=_FFReadtext(8) MsgBox(0,"",$sss) Local $sRetVal = _FFCmd(".documentElement.textContent.slice(10,3000);", 10000) If Not @error And $sRetVal <> "_FFCmd_Err" Then $sRetVal = __FFFilterString($sRetVal, 8) MsgBox(0,"",$sRetVal) EndIf EndIf Exit Edited November 15, 2012 by sleep365
Danp2 Posted November 15, 2012 Posted November 15, 2012 _FFReadText does the following:Retrieves the text with a call to FFCmdFilters the result with a call to __FFFilterStringEssentially, you are using a modified version of _FFReadText when you execute this code, which uses slice() to only return a portion of the string. You can modify this as needed to fit your needs.You are on your own when it comes to dealing with the Chinese text. Latest Webdriver UDF Release Webdriver Wiki FAQs
sleep365 Posted November 15, 2012 Author Posted November 15, 2012 (edited) i used the new version of FF with "0.6.0.1b-8" Thank you very much! I' will try it later. Edited November 15, 2012 by sleep365
Orao Posted February 26, 2014 Posted February 26, 2014 (edited) I have exactly the same problem, how did you solve it? I need to read a website from Firefox, but if the site has some foreign characters like "č", "đ", or "ö", "ü", they are not displayed correctly. My autoit script uses UTF8 wit boom encoding, and i am using the FF.au3 include, but it doesnt work. Here is an example that doesnt work: #include <FF.au3> _FFStart("www.wetter.de","", 2) $text = _FFReadtext() MsgBox(4096,"",$text) Any help how to get the foreing lagnuages characters to display corrrectly? (Characters like "č", "Ć", "ü"..etc) Edited February 26, 2014 by Orao
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now