Jump to content

Dictionary, Trimming down HTML


Recommended Posts

if $str2 = "NotFound" Then
           exit
       EndIf

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

if $str2 = "NotFound" Then
            exit
        EndIf
Precisely :P

I should have made a statement rather than ask a question because the '?' which was simply a question mark at the end of my ..er question, was possibly interpreted as standing for something unknown. So was the ? for unknown or was it just a ?? (But please don't ask "Why did you write ???")

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Yes

Here's one way to do it if you don't want to make your own gui with a listview

#include <array.au3>
 #include <string.au3>
 #include <INet.au3>
 #include <timers.au3>
 #include <listviewconstants.au3>
 
 $tofind = "search";hammer"
 $mystr = "http://dictionary.reference.com/browse/" & $tofind
 $str = _INetGetSource($mystr)
 $str = StringTrimLeft($str, StringInStr($str, '<td width="35" class="dnindex">1.</td> <td>') - 1)
 
 $str = StringReplace($str, '<div class="ety"> <b>Origin:', '<span class="sectionLabel">Synonyms:')
 
 ConsoleWrite(@extended & @CRLF)
 $str = _StringBetween($str, '<td width="35" class="dnindex">1.</td> <td>', '<span class="sectionLabel">Synonyms:')
 $lines = StringSplit($str[0], '<td width="35" class="dnindex">', 1)
 $lines[1] = "1. " & $lines[1]
 
 $t1 = _Timer_SetTimer(0, 20, "Expand")
 $newwid = 1000
 _ArrayDisplay($lines)
 For $n = 1 To $lines[0]
     $lines[$n] = StringRegExpReplace($lines[$n], "(<.*?>)", "")
 Next
 
 $t1 = _Timer_SetTimer(0, 20, "Expand")
 $newwid = 1200
 _ArrayDisplay($lines);<--now gives 14 results
 
;version II
 $lines = "1. " & StringReplace($str[0], '<td width="35" class="dnindex">', @CRLF)
 
 $lines = StringRegExpReplace($lines, "(<.*?>)", "")
 MsgBox(262144, "result ", $lines)
 
 Func expand($a, $b, $c, $d)
     If WinExists("Array: ListView Display") Then
         
         _Timer_KillTimer(0, $t1)
         $hlv = ControlGetHandle("Array: ListView Display", "", "[CLASS:SysListView32;INSTANCE:1]")
         $pitch = _SendMessage($hlv,$LVM_GETITEMSPACING,1,0)
         $pitch = $pitch/0xffff;get high word for vertical spacing
         WinMove("Array: ListView Display", "", 100, 80, $newwid, 100 + ($lines[0]+1)*$pitch)
         _SendMessage($hlv, $LVM_SETCOLUMNWIDTH, 1, $newwid )
     EndIf
 
 EndFunc ;==>expand
Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

@martin, that code gives a pitch not declared error, I may as well try coding by own listview

No it doesn't :P

You can't be running what I posted, or you have a different version of AutoIt which is the reason, but $pitch is set before it is used and I haven't set the option "MustDeclareVars". _SendMessage requires SendMessage.au3 but that is already included in WinAPI.au3 which is included in INet.au3.

But making your own listview is probably better.

EDIT: spelling - see next post.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

No it doesn't :P

....... and I haven't set the option "MustDeclareCars".

If you have that Opt() then you and I are not running the same version either.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

If you have that Opt() then you and I are not running the same version either.

:P Well it stops you having variables like $mercedes and $ford.

On the other hand maybe I meant "MustDeclareVars", I'll correct my post.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

:P Well it stops you having variables like $mercedes and $ford.

It might be a good idea but I'm not sure that I want to be the one to ask Valik for another Opt().

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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