#qa | Logs for 2019-04-02

« return
[15:12:20] -!- boru [boru!~boru@88.98.gxp.sz] has joined #qa
[15:12:23] <Bytram> Recommended change:
[15:12:23] <Bytram> Replace:
[15:12:23] <Bytram> $temp=extract_text($parts[$i],"<span class=\"wob_t\" style=\"display:inline\">","</span>");
[15:12:23] <Bytram> with:
[15:12:23] <Bytram> $temp1=extract_text($parts[$i],"<span class=\"wob_t\" style=\"display:inline\">","</span>");
[15:12:24] <Bytram> $temp=preg_replace("/[^0-9]/", "", $temp1);
[15:12:28] <Bytram> And, as far as I can tell, sample data would look like:
[15:12:30] <Bytram> <td style="padding-left:5px;padding-right:2px;text-align:right;vertical-align:top;white-space:nowrap"><span class="wob_t" style="display:inline">51°F</span></td>
[15:12:33] <Bytram> <td style="color:#666;padding-left:2px;padding-right:5px;text-align:left;vertical-align:top;white-space:nowrap"><span class="wob_t" style="display:inline">36°F</span></td>
[15:12:36] <Bytram> <td style="padding-left:5px;padding-right:2px;text-align:right;vertical-align:top;white-space:nowrap"><span class="wob_t" style="display:inline">61°F</span></td>
[15:12:39] <Bytram> <td style="color:#666;padding-left:2px;padding-right:5px;text-align:left;vertical-align:top;white-space:nowrap"><span class="wob_t" style="display:inline">39°F</span></td>
[15:12:49] <Bytram> <td style="padding-left:5px;padding-right:2px;text-align:right;vertical-align:top;white-space:nowrap"><span class="wob_t" style="display:inline">50°F</span></td>
[15:12:49] <Bytram> <td style="color:#666;padding-left:2px;padding-right:5px;text-align:left;vertical-align:top;white-space:nowrap"><span class="wob_t" style="display:inline">32°F</span></td>
[15:12:49] <Bytram> <td style="padding-left:5px;padding-right:2px;text-align:right;vertical-align:top;white-space:nowrap"><span class="wob_t" style="display:inline">48°F</span></td>
[15:12:51] <Bytram> <td style="color:#666;padding-left:2px;padding-right:5px;text-align:left;vertical-align:top;white-space:nowrap"><span class="wob_t" style="display:inline">40°F</span></td>
[15:12:56] <boru> Sweet chocolate christ.
[15:13:05] <Bytram> yuppers
[15:13:24] -!- AndyTheAbsurd [AndyTheAbsurd!~Andy@207.246.jjm.rjp] has joined #qa
[15:14:01] <boru> So, what is the goal exactly?
[15:14:04] <Bytram> the PHP code seems to make a lot of hardwired assumptions about the HTML... like order of attributes in the TD element. :/
[15:14:18] <Bytram> produce the output for ~weather <location>
[15:14:34] <AndyTheAbsurd> can you post the line with the replacement code again? I missed it.
[15:14:36] <boru> What about this re though?
[15:15:01] <Bytram>
[15:15:07] <Bytram> Replace:
[15:15:07] <Bytram> $temp=extract_text($parts[$i],"<span class=\"wob_t\" style=\"display:inline\">","</span>");
[15:15:07] <Bytram> with:
[15:15:07] <Bytram> $temp1=extract_text($parts[$i],"<span class=\"wob_t\" style=\"display:inline\">","</span>");
[15:15:08] <Bytram>
[15:15:19] <Bytram> $temp=preg_replace("/[^0-9]/", "", $temp1);
[15:15:22] <Bytram>
[15:15:32] <boru> Okay, so just strip all numeric values?
[15:15:35] <Bytram> (nod nod
[15:15:50] <boru> Well, that ought to do it.
[15:16:07] <Bytram> and yet #debug shows PHP barfing while trying to do the calculation.
[15:16:21] <Bytram> Like this:
[15:16:23] <Bytram> <exec> STDERR IN [php scripts/weather.php '~weather' 'boston' 'Bytram']: PHP Notice: A non well formed numeric value encountered in /home/chris/Downloads/Exec/exec-irc-bot-master/scripts/weather_lib.php on line 197
[15:16:24] <boru> Can you get it to dump what it's trying to match on?
[15:16:30] <Bytram> nope
[15:16:44] <Bytram> is all being done on one of cmn32480's machines
[15:16:55] <Bytram> here's the source url:
[15:17:21] <Bytram> urgh, hold on
[15:17:49] <Bytram> wget --user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20100101 Firefox/14.0 Iceweasel/14.0" --continue --output-document=wx.html --output-file=wx.log "http://www.google.com.au/search?gbv=1&fheit=1&q=weather+Boston"
[15:19:02] <Bytram> there's a boat load of javascript at the top. scroll down to <body>
[15:19:22] <Bytram> I extracted all text between <body> and </body>
[15:19:31] <boru> Seems a bit overkill to get it from goolag.
[15:19:43] <Bytram> true
[15:20:44] <Bytram> then split up into html phrases, find matching TDs with a certain style attached, and then extract the temperature from that
[15:20:46] <boru> yr.no have PHP/XML API apparently.
[15:20:52] <Bytram> right
[15:21:13] <Bytram> I've glanced at some PHP stuff online, but never did anything with it personally.
[15:21:42] <Bytram> just seemed to be a macro processor written by someone who did not understand computer language grammars
[15:22:04] <Bytram> ran into problems, patched those, found more problems, patched some more, etc.
[15:22:21] <boru> Didn't php start out as a project for the author to learn C?
[15:22:28] <Bytram> no idea
[15:22:28] <boru> And what's why it's such a security minefield?
[15:22:42] <Bytram> would not surprise me in the least
[15:23:27] -!- AndyTheAbsurd [AndyTheAbsurd!~Andy@207.246.jjm.rjp] has parted #qa
[15:24:08] <Bytram> it... works, but is *noisy* about getting the weather. Thought it was something I might be able to wrangle a quick patch, but no joy.
[15:24:33] <boru> I suspect it's going to be something related to unicode crap.
[15:25:01] <Bytram> on 2nd thought, I think cmn32480 is applying updates to the box, so there might well be a new version of PHP trying to process the "downlevel" code with new semantics being applied to old syntax.
[15:25:24] <Bytram> No idea, but that is a genuine possibility.
[15:26:09] <Bytram> he sent me a copy of the weather lib file. If you want it, I can send it to you... but be prepared for some "ickyness"
[15:26:51] <boru> No no, that's quite alright.
[15:27:04] <Bytram> somehow I thought you might say that!
[15:27:17] <Bytram> thanks anyway for the input and feedback!
[15:27:26] <boru> Well, sorry I couldn't be of more use.
[15:27:26] <Bytram> ok, really should get going.
[15:27:30] <Bytram> np
[15:27:32] -!- boru [boru!~boru@88.98.gxp.sz] has parted #qa