Jump to content

How to get this site parsed with html and javscript?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
10 replies to this topic

#1
arxh

arxh

    Newbie

  • Members
  • PipPip
  • 24 posts
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.


#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,722 posts
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?
sudo rm -rf /

#3
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
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 ^^

#4
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,722 posts
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.
sudo rm -rf /

#5
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
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.


#6
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,722 posts
By "other program" I meant "a program you write yourself." I don't think too many people have IE6 or lower these days.
sudo rm -rf /

#7
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
They use IE6 at the place where i did my vacation job XD

#8
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,722 posts
Update fail.
sudo rm -rf /

#9
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
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.

#10
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,722 posts
Yeah, I've been thinking that too.
sudo rm -rf /

#11
JenniC

JenniC

    Newbie

  • Members
  • Pip
  • 6 posts
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.