Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


"gather file; read and report"
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

"gather file; read and report"

eastoncheastonch Member
edited September 2012 in General

Hi guys;

I'm wondering about a small coding project that could greatly help me in my organisation.
Currently at work; (McDonalds) we have this shift-scheduling system called "McTime" (don't fucking laugh). and it displays information once logged in about each day; and who's in. it displays it through the use of HTML tables, for example:
<tr> <td class="s_day_td_crew"> Pauline Robinson </td> <td class="s_day_td_crew"> 09:00-17:00 </td> </tr>
image

Would there be a way to be able to "strip" a html file through PHP to look for my name "Christopher Easton" then find the hour below it? It's more annoying since there's one class, not two; when it comes to the table.

I would then take the hour for that day and then output it into my own little DB; from here, be able to work out approximate pay; how long my break would be, etc. It saves me manually entering it on my Excel Spreadsheet which is too messy for me to repair how I want it to be... And something like this could be fun.

Any ideas? I've thought about maybe reading the remote file and stripping it down in an array and string replacing to just find names and times... but that seemed like alot of work, and there has to be a simpler way.

Cheers,.
Chris.

Comments

  • I do this sort of stuff with python but for php see:
    http://php.net/manual/en/simplexmlelement.xpath.php
    You can give the exact HTML and I might help you with the code if I have time to play with PHP later. But you've probably figured it out already by then :)

  • sleddogsleddog Member
    edited September 2012

    This might be a start...

    curl -s http://someURL | grep -A3 "Adam Smart"

    -A3 prints 3 lines after the line with 'Adam Smart'

    That should give you your times on the last line. If it does you can add tail to display only the last line...

    curl -s http://someURL | grep -A3 "Adam Smart" | tail -n1

  • what about javascript?

  • PhilNDPhilND Member
    edited September 2012

    Yes. Domxpath in PHP can do it.

    Go look into it, awesome for making web scrapers too.

    http://php.net/manual/en/class.domxpath.php

    Phil

  • joepie91joepie91 Member, Patron Provider

    I'm happy to see XML parsers be the first thing to be suggested, instead of regex :)

  • Alright; quite a lot I need to take in; cheers @sleddog for the starting point; I think I'll look into using curl (I guess I could just use PHP and use the shell_exec function?

  • @joepie91 said: I'm happy to see XML parsers be the first thing to be suggested, instead of regex :)

    I always thought that bash, grep, sed and awk were parsers? :P

  • @eastonch said: I think I'll look into using curl (I guess I could just use PHP and use the shell_exec function?

    There's a curl extension in PHP...

    Thanked by 1eastonch
Sign In or Register to comment.