Jump to content

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


sleep365
 Share

Recommended Posts

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
Link to comment
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.

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)

Link to comment
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
Link to comment
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)

Link to comment
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.

Link to comment
Share on other sites

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
Link to comment
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. ;)

Link to comment
Share on other sites

  • 1 year later...

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...