Extracting info from external web page

This is a discussion on "Extracting info from external web page" within the JavaScript Forum section. This forum, and the thread "Extracting info from external web page are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jun 26th, 2008, 08:02
ForcesResources's Avatar
SuperMember

SuperMember
Join Date: Jun 2008
Location: Barnsley, UK
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Extracting info from external web page

Hi all

I am trying to automate a process that enables me to collect the latest National website

There is a segment of the page HTML that goes
HTML: Select all
          <div id="lottoResultsHeader" >
              <h2><img src="/player/i/homepage/lottoheader218x27.gif" alt="Lotto results" /></h2>

              <p class="resultsText">Draw  1305 Wed 25 Jun 08</p>
                <div id="lottoDraw">
                <img src="/player/i/balls/lotto_11.gif" alt="ball 11" width="19" height="19" class="lottoball" />
                <img src="/player/i/balls/lotto_12.gif" alt="ball 12" width="19" height="19" class="lottoball" />
                <img src="/player/i/balls/lotto_22.gif" alt="ball 22" width="19" height="19" class="lottoball" />
                <img src="/player/i/balls/lotto_23.gif" alt="ball 23" width="19" height="19" class="lottoball" />
                <img src="/player/i/balls/lotto_24.gif" alt="ball 24" width="19" height="19" class="lottoball" />
                <img src="/player/i/balls/lotto_36.gif" alt="ball 36" width="19" height="19" class="lottoball" />
                <img src="/player/i/balls/lotto_26.gif" alt="Bonus ball 26" width="19" height="19" class="lottoballlast" /><span class="star">Bonus Ball</span>
            </div>
Is there a way to extract the numbers ie 11, 12, 22, 23, 24, 36, 26 from the code.
There is a load of code before this but I have started the code here as the div has an id.

Thanks in advance for any help.
john
Reply With Quote

  #2 (permalink)  
Old Jun 26th, 2008, 09:36
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,956
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Re: Extracting info from external web page

ok.. here is the process.... Im not going to write it for you but will give you what you need to do.

Firstly, you cant do this in javascript to my knowledge, you would need ASP or PHP.

Using fopen (php) or an HTTP request object (ASP) you would need to request the page.

Then using a regular expression or splitting the string into an array you would need to isolate this section:-
<div id="lottoDraw">
images code here
</div>

Then you would need to split that section into an array using the following delimeter:-
<img src="/player/i/balls/lotto_

What you are left with is an array containing all the draw info.
each element of the array will look like this:-
11.gif" alt="ball 11" width="19" height="19" class="lottoball" />

This just leaves you the task of looking for the occurence of .gif .... in code just isolate that and strip it, and everything else after it.

Do that for each array element and you are left with your draw info.

You will need to handle the bonus ball differerently but should you get this far, you should easy be able to work out that process.

Hope this helps....

btw.... once youve decided on a language to use let me know in this thread and i will move it to the appropriate forum.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
  #3 (permalink)  
Old Jun 26th, 2008, 10:12
ForcesResources's Avatar
SuperMember

SuperMember
Join Date: Jun 2008
Location: Barnsley, UK
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Extracting info from external web page

Thanks Rob

It will be php as that is what I premeditatedly use.

I have having trouble already though. I get nothing from thye fopen and when I try and get the filesize I get nothing back
PHP: Select all

<?php echo filesize("http://www.national-lottery.co.uk/player/p/results/results.do");?>

Could this have anything to do with the fopen not working?

John
Reply With Quote
  #4 (permalink)  
Old Jun 27th, 2008, 07:30
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,956
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Re: Extracting info from external web page

I'm not totally sure filesize will work on a remote file...

Try using:-
$myVar = file_get_contents("http://yoururl");
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
  #5 (permalink)  
Old Jun 27th, 2008, 17:43
CloudedVision's Avatar
Nerdy Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 1,229
Blog Entries: 9
Thanks: 2
Thanked 38 Times in 38 Posts
Re: Extracting info from external web page

fopen will not work on external servers. You want PHP's cURL.
__________________
CloudedVision, WebForumz Moderator
Web Design And Development: Other Road Design | Problems with IE6?: KApp | My Blog: Only Nerds Allowed
Last Blog Entry: Hilarious Rapper (Jul 29th, 2008)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
A little help needed - Select info from DB and display on page weasel PHP Forum 3 Jul 7th, 2007 07:22
How to put your menu/static info. on every page lmc148 Starting Out 18 Jun 29th, 2007 09:53
need to onclick to open info in div on same page apster JavaScript Forum 2 Apr 30th, 2007 09:56
Displaying diff info on the same page waheeddin Web Page Design 1 Feb 23rd, 2007 19:56
Drop down menu info displayed on same page? Dopeness JavaScript Forum 1 Jan 10th, 2006 07:34


All times are GMT. The time now is 10:29.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43