Jump to content

Help: HTML special characters to regular text


spyrorocks
 Share

Recommended Posts

Hello.

I need some help. i am grabbing some html from a website but when it returns it it replaces some special accented characters with html equilivents, like & # 3 9 ; (spaces added to make it show)

for example.

does anyone know of a function that i can use that would allow me to turn them back into regular letters?

edit: edit: crap.

Edited by spyrorocks
Link to comment
Share on other sites

  • Moderators

Hello.

I need some help. i am grabbing some html from a website but when it returns it it replaces some special accented characters with html equilivents, like & # 3 9 ; (spaces added to make it show)

for example.

does anyone know of a function that i can use that would allow me to turn them back into regular letters?

edit: edit: crap.

There's not a function I'm aware of, but you could write your own UDF to do it (with StringReplace())

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Yeah i guess. does stringreplace() accept arrays as the search and replace variables? because if it dont then this could be a pain to do because there are soo many special character codes.

Link to comment
Share on other sites

  • Moderators

Yeah i guess. does stringreplace() accept arrays as the search and replace variables? because if it dont then this could be a pain to do because there are soo many special character codes.

Do you know what an array is and what it returns when called?... if you do, then you know the answer to that question.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Yes i do.

Im was just wondeing cuz i never used an array with stringreplace() before, and some functions accept an array.

That doesn't really make any sense, but ok.

This might start it off, there are obviously more, but you can take the time to put all of them in there.

Func _HTMLReplace($sString)
    Local $aReplace[5] = ['', '"', '&', '<', '>']
    Local $aEntity[5] = ['', '"', '&', '<', '>']
    Local $aDecimal[5] = ['', '"', '&', '<', '>']
    Local $aHex[5] = ['', '"', '&', '<', '>']
    For $iCC = 1 To UBound($aReplace) - 1
        $sString = StringReplace($sString, $aEntity[$iCC], $aReplace[$iCC])
        $sString = StringReplace($sString, $aDecimal[$iCC], $aReplace[$iCC])
        $sString = StringReplace($sString, $aHex[$iCC], $aReplace[$iCC])
    Next
    Return $sString
EndFunc

Edit:

Dammit, code tags are converting some of the chars... I'll upload the example.

HTMLReplace.au3.txt

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

OK thanks for getting me started. Ill add some more.

You can also use COM and the .innerText property of an object. This is what _IEBodyReadText uses on the document body object to return rendered text.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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