Damein Posted April 25, 2011 Share Posted April 25, 2011 Alright, so I'm still fairly newbish to StringReg (Hence why I am doing a script using it) and I am stuck. I successfully pulled some data from a website that I want but there's a snag on the next part. The website I am pulling data from is Weather.com. I am currently working on pulling the images for the days. Here is the section I need: <img src="http://s.imwx.com/v.20100719.135915/img/wxicon/130/26.png" alt="Cloudy" width="130" height="130"></td><!-- Column 1 --> But the problem is, its on a new line in the script and there are a lot more <img src=" in the code. Now, I did get it to work using a couple of other commands, but it seems like I should be able to shorten it down. If so, let me know. Here is how I did it: $ImageForToday = StringRegExp($sSource,'(?i)(?s)<span class="twc-forecast-when twc-none">Right Now</span>(.*?)" alt',1) $ImageString = _ArrayToString($ImageForToday) $ImageStringStrippedOfSpaces = StringStripWS($ImageString,8) $ImageStringCleanedUp = StringReplace($ImageStringStrippedOfSpaces, '<imgsrc="', "") And that would produce the correct image link. Thanks! Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
GEOSoft Posted April 25, 2011 Share Posted April 25, 2011 What are some of the image tags that you don't want to match? Matching the one you gave is easy but the trick here will be to find something that is consistant that you can anchor to and I'm even looking at that <-- column 1 -->. If I remembered what all of the alt= possibilities where it could also help. 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 More sharing options...
Damein Posted April 25, 2011 Author Share Posted April 25, 2011 (edited) Well, the only one on that page I would need help with is that one. The other ones are unique, because they look like this: <td class="twc-col-2 twc-forecast-icon"><a href="/weather/tenday/47130" from="today_daypartforecast_icon"><img src="http://s.imwx.com/v.20100719.135915/img/wxic/72/12.png" width="72" height="72" alt="Rain / Thunder" ></a></td><!-- Column 2 --> Edited April 25, 2011 by Damein Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
GEOSoft Posted April 25, 2011 Share Posted April 25, 2011 I posted this just as the Forum went off-line for backup. It looks like the Column 1 bit is a viable anchor $a_Rslt = StringRegExp($sSrc, "(?i)(?m:^)\s*<img\ssrc=.+(http.+\.png).*column 1.*-->", 1) If NOT @Error Then MsgBox(0, "Result", "The image you are after should be" & @CRLF & $a_Rslt[0]) 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 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