motionman95 Posted February 7, 2009 Share Posted February 7, 2009 I searched the Documentation, and most of the examples I found involve the browser launching and then the source code being read. What I wanted was to do was use _INetGetSource to well, get the source and then using some IE function to read some code from the page. Would that work? In all examples I found you had to use an open browser, or a browser object. Thanks for any replies! Link to comment Share on other sites More sharing options...
KaFu Posted February 7, 2009 Share Posted February 7, 2009 Any special reason why not to use the IE object? You can do it hidden in the background, you don't have to invoke a GUI. _IEDocReadHTML ( ByRef $o_object ) OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
motionman95 Posted February 7, 2009 Author Share Posted February 7, 2009 Any special reason why not to use the IE object? You can do it hidden in the background, you don't have to invoke a GUI._IEDocReadHTML ( ByRef $o_object )Is it faster than using _INetGetSource and StringRegExp? Link to comment Share on other sites More sharing options...
KaFu Posted February 7, 2009 Share Posted February 7, 2009 I'm not sure, escp. StringRegExp() will use some cpu-power, but on the other hand I guess that's the same way it's done in the ie.au3 (without looking). Maybe it's a bit slower. But I has been done and you'll save a lot of coding time utilizing it instead of reinventing the wheel ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
motionman95 Posted February 8, 2009 Author Share Posted February 8, 2009 I'm having problems. I'm using this code: $results = StringRegExp($html,"(?U)<a>(.*)</a>",3) But where it says <a(HERE)>(.*)</a> I want to put something that means "any thing can be here" Help please? Link to comment Share on other sites More sharing options...
Robjong Posted February 8, 2009 Share Posted February 8, 2009 Hey, THis should work. (?s) enables "." to match newlines, might not be needed. $results = StringRegExp($html,"(?s)(?U)<a.*>(.*)</a>",3) Link to comment Share on other sites More sharing options...
motionman95 Posted February 8, 2009 Author Share Posted February 8, 2009 Hey, THis should work. (?s) enables "." to match newlines, might not be needed. $results = StringRegExp($html,"(?s)(?U)<a.*>(.*)</a>",3) Thanks, that worked! The only problem I'm having now is that when the text in between the <a></a> tags Has an "|" as in <a>ABC | 123</a> It will only show "ABC " why is that? And is there a solution? Link to comment Share on other sites More sharing options...
Authenticity Posted February 8, 2009 Share Posted February 8, 2009 $html = '<a>ABC | 123</a>' $results = StringRegExp($html,'(?s)(?U)<a.*>(.*)</a>', 1) Dim $Text = '' For $i = 0 To UBound($results)-1 $Text &= $results[$i] & @CRLF Next MsgBox(0x40, 'Title', $Text) It does match the '|' and ' acb' as well but the _ArrayDisplay() is referring to '|' as special character. Link to comment Share on other sites More sharing options...
TerarinK Posted February 8, 2009 Share Posted February 8, 2009 Ahhh, thank you Authenticity this would have gotten me all night if I didn't refresh this $asResults = StringRegExp($sTest,"(?i:<a.*>)(.*?)(?i:</a>)",3) 0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E Link to comment Share on other sites More sharing options...
TerarinK Posted February 8, 2009 Share Posted February 8, 2009 Here is the correct way a viewing your data: #include <array.au3> $sTest = "<a src=""bitch.bitch.com"">ABC | 123</a>" $asResults = StringRegExp($sTest,"(?i:<a.*>)(.*?)(?i:</a>)",3) _ArrayDisplay($asResults, "Test String", -1, 0, "", "")oÝ÷ Ù8b±×¥z׬¶ªºjº_®²¢êßwb(«¢+Ø¥¹±Õ±ÐíÉÉä¹ÔÌÐì((ÀÌØíÍQÍÐôÅÕ½Ðì±ÐíÍÉôÅÕ½ÐìÅÕ½Ðí¥Ñ ¹¥Ñ ¹½´ÅÕ½ÐìÅÕ½ÐìÐí ðÄÈ̱Ðì½ÐìÅÕ½Ðì((ÀÌØíÍIÍÕ±ÑÌôMÑÉ¥¹IáÀ ÀÌØíÍQÍаÅÕ½Ðì ý¤è±Ðí¸¨Ðì¤ ¸¨ü¤ ý¤è±Ðì½Ðì¤ÅÕ½Ðì°Ì¤()}ÉÉå¥ÍÁ±ä ÀÌØíÍIÍÕ±ÑÌ°ÅÕ½ÐíQÍÐMÑÉ¥¹ÅÕ½Ðì°´Ä°À°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì But that deletes the " " from your findings 0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E Link to comment Share on other sites More sharing options...
motionman95 Posted February 8, 2009 Author Share Posted February 8, 2009 What I'm trying to do is read the result Titles from the results of a google search page. This is the code I'm using: $html = _INetGetSource("http://www.google.com/search?hl=en&q=spiderman") $results = StringRegExp($html,"(?s)(?U)<li.*><h3.*><a.*>(.*)</a>", 3) _ArrayDisplay($results) But this is what it returns, and it is not completely correct: Link to comment Share on other sites More sharing options...
Authenticity Posted February 8, 2009 Share Posted February 8, 2009 (edited) So you need something more like ((?(<em>)|(<b>)))?Didn't test it though.Edit: This is quite sophisticating :#include <INET.au3> #include <Array.au3> $html = _INetGetSource("http://www.google.com/search?hl=en&q=spiderman") $results = StringRegExp($html,"(?s)(?U)<li.*><h3.*><a.*>(.*)</a>", 3) For $i = 0 To UBound($results)-1 $results[$i] = StringRegExpReplace($results[$i], '((</?b>)|(</?em>))', '') Next _ArrayDisplay($results) Edited February 8, 2009 by Authenticity Link to comment Share on other sites More sharing options...
DaleHohm Posted February 8, 2009 Share Posted February 8, 2009 I have nothing against StringRegEx, but this is how it would be done with IE.au3... #include <IE.au3> $oIE = _IECreate("http://www.google.com/search?hl=en&q=spiderman") $oLinks = _IELinkGetCollection($oIE) For $oLink in $oLinks If String($oLink.classname) = "l" Then ConsoleWrite(_IEPropertyGet($oLink, "innertext") & @CRLF) Next 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 More sharing options...
Moderators SmOke_N Posted February 8, 2009 Moderators Share Posted February 8, 2009 I have nothing against StringRegEx 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 More sharing options...
motionman95 Posted February 8, 2009 Author Share Posted February 8, 2009 I have nothing against StringRegEx, but this is how it would be done with IE.au3... #include <IE.au3> $oIE = _IECreate("http://www.google.com/search?hl=en&q=spiderman") $oLinks = _IELinkGetCollection($oIE) For $oLink in $oLinks If String($oLink.classname) = "l" Then ConsoleWrite(_IEPropertyGet($oLink, "innertext") & @CRLF) Next Dale Is there a way to make it invisible? Link to comment Share on other sites More sharing options...
Authenticity Posted February 8, 2009 Share Posted February 8, 2009 Yup, but the object is going to be loaded to the memory anyway. $oIE = _IECreate(Default, 0, 0, 0, 0) Link to comment Share on other sites More sharing options...
BrettF Posted February 8, 2009 Share Posted February 8, 2009 Bright spark you are... How about you read the help file for _IECreate, then ask the same question while posting your answer? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
DaleHohm Posted February 8, 2009 Share Posted February 8, 2009 Is there a way to make it invisible?Yes, look at the docs for _IECreate()Dale@Sm0ke - honest! 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 More sharing options...
motionman95 Posted February 8, 2009 Author Share Posted February 8, 2009 (edited) Thanks guys for being patient and all the help. I promise, this is the last question, LOL. Anyway, I'm trying to detect the double-click on a List View item and then output (using ConsoleWrite) the name of the item. For instance: I double click an item named "Free Games" and "Free Games" is the output. I tried searching the forum, but the code I found was waaaayyy out dated and threw a bunch of errors. Any ideas? Once again, thanks guys! Edited February 8, 2009 by motionman95 Link to comment Share on other sites More sharing options...
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