Sign in to follow this  
Followers 0
sleep365

About Firefox:How could i get the web Text( UTF-8 Code) use _FFReadText?

12 posts in this topic

#1 ·  Posted (edited)

I am in china. The result is unrecognizable .

#include <FF.au3>

Local $wait_seconds = 3

Local $sss

If _FFConnect() Then

_FFOpenURL('http://www.baidu.com/')

$sss=_FFReadtext(8)

MsgBox(0,"",$sss)

EndIf

Exit

=========================================

the text is what i want get

搜索设置|登录注册

新 闻 网 页 贴 吧 知 道 音 乐 图 片 视 频 地 图

百科 文库 hao123 | 更多>>

把百度设为主页把百度添加到桌面

加入百度推广 | 搜索风云榜 | 关于百度 | About Baidu

©2012 Baidu 使用百度前必读 京ICP证030173号

Attached Thumbnails

  • Posted Image
Edited by sleep365

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by mihaibr

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites

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,

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
Share on other sites

@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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites

@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.

Share this post


Link to post
Share on other sites

#9 ·  Posted (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 by sleep365

Share this post


Link to post
Share on other sites

_FFReadText does the following:

  • Retrieves the text with a call to FFCmd
  • Filters the result with a call to __FFFilterString
Essentially, 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. ;)

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

i used the new version of FF with "0.6.0.1b-8"

Thank you very much! I' will try it later.

Edited by sleep365

Share this post


Link to post
Share on other sites

#12 ·  Posted (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 by Orao

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0