Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

How to get this site parsed with html and javscript?

HTML

  • Please log in to reply
10 replies to this topic

#1 arxh

arxh

    CC Newcomer

  • Just Joined
  • PipPip
  • 24 posts

Posted 28 July 2010 - 09:02 AM

Ok, so I am trying to create a web paged that can be self contained and not dependent on a server. I was wondering if anyone knew of a way to get this site:

http://sports.espn.g...ttomline/scores

to open and parsed with javascript. basically it is a live view of all of the MLB scores. I dont want to use PHP because a browser such as chrome can not render it on its own.


This is actually for a chrome extension. I had this idea about an extension that would alert you when your team scored. I found that web page with free scores and got excited, but it doesnt look like it is going to work too well.

Does anyone know what I am talking about?


if so,


any help would be appreciated!

Edited by arxh, 28 July 2010 - 09:53 AM.

  • 0

#2 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 29 July 2010 - 04:53 PM

Ok, so lemme get this straight - you want to parse a webpage, strip data out, then render it on your own in a local page?
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'


#3 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 29 July 2010 - 11:55 PM

On 1 hand i think Javascript can only ask for websites of the same domain making this task impossible.
On the other hand.. Vswe once made an extension for chrome which showed new posts of CodeCall. So i suppose it's possible in some way ^^
  • 0

#4 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 30 July 2010 - 12:20 AM

You could use another program to make the HTTP requests and then rewrite the page based on a template on the fly. I did something like that a while ago.
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'


#5 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 30 July 2010 - 12:36 AM

Could you specify "another program". This is actually quite interesting :)

Edit: I suppose you mean stuff like flash .

(this works in IE6 and lower :D:-P
<html>
   <head>
       <script type="text/javascript">
       function load(){
           if (window.XMLHttpRequest)
        {
          xmlhttp=new XMLHttpRequest();
        }
        else
        {
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
         }
           xmlhttp.onreadystatechange=function()
        {         

          if (xmlhttp.readyState==4 && xmlhttp.status==200)
          {
              htmlcode=xmlhttp.responseText;
            var start, end;
            for(var i=0 ; i<htmlcode.length && end ==null ; i++){
                 if(htmlcode.substring(i, i+18)=='<div id="siteSub">'    )    {
                   start =(i+= 18);
                   }
                 if(start != null && end==null && htmlcode.substring(i, i+6)=='</div>') {
                   end = i;
                   }    
            }    
            document.getElementById('myDiv').innerHTML = htmlcode.substring(start, end);                     
           
          }
         }
            xmlhttp.open("GET", "http://en.wikipedia.org/wiki/JavaScript", true);
            xmlhttp.send(null);            
        }
        
           
       </script>
      <title>Enter the title of your HTML document here</title>
   </head>
   <body>
     <input type="button" onclick="load()" value="klik"></input>
      <div id="myDiv"></div>
   </body>
</html>

Edited by wim DC, 30 July 2010 - 01:16 AM.

  • 0

#6 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 30 July 2010 - 08:12 AM

By "other program" I meant "a program you write yourself." I don't think too many people have IE6 or lower these days.
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'


#7 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 30 July 2010 - 10:54 AM

They use IE6 at the place where i did my vacation job XD
  • 0

#8 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 30 July 2010 - 05:31 PM

Update fail.
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'


#9 BlaineSch

BlaineSch

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1559 posts

Posted 30 July 2010 - 07:30 PM

I have IE6, just tested and works ^_^

I think I mainly use it for validating my HTML pages work fine, but I suppose if your wanting it to be more universal you could use this:

phpquery - Project Hosting on Google Code

Looks neat! Works just like jQuery but server side. Sitepoint gave away a jQuery eBook if anybody wants a copy.

EDIT:
I vote for a different link color, it's too similar to the regular font color.
  • 0

#10 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 30 July 2010 - 10:47 PM

Yeah, I've been thinking that too.
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'


#11 JenniC

JenniC

    CC Lurker

  • New Member
  • Pip
  • 6 posts

Posted 02 August 2010 - 10:59 AM

A script like this perhaps,

# Script BottomLine.txt
var str s ; cat "[URL]http://sports.espn.go.com/mlb/bottomline/scores[/URL]" > $s
while ( { sen -r "^=&\&^" $s } > 0 )
do
    stex "^=^]" $s > null
    stex "]^&^" $s
done



Save this script in file C:/Scripts/BottomLine.txt, run it with command

script "C:/Scripts/BottomLine.txt"

You can get more fancy and use the internet sessions feature - http://www.biterscri...edinternet.html .

Make sure you have the permission of the espn to download scores they have compiled.
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download