techPowerUp! Forums

Go Back   techPowerUp! Forums > Software > Programming & Webmastering

Reply
 
Thread Tools
Old Nov 1, 2010, 12:39 PM   #1
TIGR
2000 Posts
 
TIGR's Avatar
 
Join Date: Aug 2008
Location: Minnesota, USA
Posts: 2,098 (1.20/day)
Thanks: 739
Thanked 1,030 Times in 598 Posts

System Specs

Parse Web Page to MySQL Db

accidental edit

Last edited by TIGR; Sep 14, 2011 at 11:33 AM.
TIGR is offline  
Reply With Quote
Old Nov 1, 2010, 12:49 PM   #2
W1zzard
Benevolent Dictator
 
W1zzard's Avatar
 
Join Date: May 2004
Location: Stuttgart, Germany
Posts: 13,793 (4.18/day)
Thanks: 184
Thanked 10,293 Times in 3,176 Posts
Send a message via ICQ to W1zzard Send a message via AIM to W1zzard Send a message via MSN to W1zzard

System Specs

just fetch the page via curl functions or file_get_contents, extract whatever info you need via simple string processing or preg_match and put it in your db
W1zzard is offline  
Reply With Quote
The Following User Says Thank You to W1zzard For This Useful Post:
Old Nov 1, 2010, 12:54 PM   #3
TIGR
2000 Posts
 
TIGR's Avatar
 
Join Date: Aug 2008
Location: Minnesota, USA
Posts: 2,098 (1.20/day)
Thanks: 739
Thanked 1,030 Times in 598 Posts

System Specs

Quote:
Originally Posted by W1zzard View Post
just fetch the page via curl functions or file_get_contents, extract whatever info you need via simple string processing or preg_match and put it in your db
Someone who properly knew what he was doing would probably understand that really well. As for me, I have some searching and studying to do.

A recent head injury has left me hazy on much of the coding and programming I once understood. At this point, all I understand is basic PHP and basic use of phpMyAdmin for MySQL. I am learning all over, as I go.

Thank you for getting me started.
TIGR is offline  
Reply With Quote
Old Nov 2, 2010, 02:39 PM   #4
Jizzler
2000 Posts
 
Jizzler's Avatar
 
Join Date: Aug 2007
Location: Geneva, FL, USA
Posts: 3,010 (1.42/day)
Thanks: 567
Thanked 606 Times in 487 Posts

System Specs

The first table.

PHP Code:
$page 'http://fah-web.stanford.edu/cgi-bin/main.py?teamnum=174132&qtype=teampage';
$html file_get_contents($page);
$html str_replace(array("\t""\n"), ''$html);

$pattern '~<TD align=left>\s(.*)\s*(</TD>|\()~U';
preg_match_all($pattern$html$matches); 
$matches[1] holds an array with the following:

PHP Code:
[0] => 06:13:59 November 022010
[1] => 2010-11-02 06:12:46
[2] => 35
[3] => 174132
[4] => 10016245
[5] => 22377
[6] => 556 of 189735
[7] => <a href=http://www.re-hq.net> http://www.re-hq.net </a> 
That handles a few of the items you want. Team ranking can come from:

PHP Code:
list($rank$teamCount) = explode(' of '$matches[1][6]); 
Or if team count isn't important, could just modify the pattern a little: '~<TD align=left>\s(.*)\s*(</TD>|\(| of)~U'. Then $matches[1][6] is just the team rank.

Last edited by Jizzler; Nov 2, 2010 at 02:48 PM.
Jizzler is offline  
Reply With Quote
The Following User Says Thank You to Jizzler For This Useful Post:
Old Nov 2, 2010, 02:44 PM   #5
TIGR
2000 Posts
 
TIGR's Avatar
 
Join Date: Aug 2008
Location: Minnesota, USA
Posts: 2,098 (1.20/day)
Thanks: 739
Thanked 1,030 Times in 598 Posts

System Specs

Quote:
Originally Posted by Jizzler View Post
The first table.

PHP Code:
$page 'http://fah-web.stanford.edu/cgi-bin/main.py?teamnum=174132&qtype=teampage';
$html file_get_contents($page);
$html str_replace(array("\t""\n"), ''$html);

$pattern '~<TD align=left>\s(.*)\s*(</TD>|\()~U';
preg_match_all($pattern$html$matches); 
$matches[1] holds an array with the following:

PHP Code:
[0] => 06:13:59 November 022010
[1] => 2010-11-02 06:12:46
[2] => 35
[3] => 174132
[4] => 10016245
[5] => 22377
[6] => 556 of 189735
[7] => <a href=http://www.re-hq.net> http://www.re-hq.net </a> 
That handles a few of the items you want. Team ranking can come from:

PHP Code:
list($rank$teamCount) = explode(' of '$matches[1][6]); 
Sir, I am much in your debt. This is invaluable to me. I will be reviewing your code and working on this project today. Thank you.
TIGR is offline  
Reply With Quote
Old Nov 2, 2010, 02:50 PM   #6
Jizzler
2000 Posts
 
Jizzler's Avatar
 
Join Date: Aug 2007
Location: Geneva, FL, USA
Posts: 3,010 (1.42/day)
Thanks: 567
Thanked 606 Times in 487 Posts

System Specs

No prob. My regex isn't always the best or most efficient pattern (I don't do enough of it to get the experience), but if you have some troubles, I can probably help on the second table tonight.
Jizzler is offline  
Reply With Quote
The Following 2 Users Say Thank You to Jizzler For This Useful Post:
Old Nov 2, 2010, 02:51 PM   #7
Helli
25 Posts
 
Helli's Avatar
 
Join Date: Feb 2010
Location: Germany, near Munich
Posts: 62 (0.05/day)
Thanks: 18
Thanked 12 Times in 11 Posts

System Specs

I have done this on other Projects for my Team.
Keep in Mind, on every Code Change the Staff will do in the Future
you have to modify your Script also. That can mean much, much work.

Helli
Helli is offline  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Any way to get a black background before a web page is loaded? Meizuman General Software 7 Jul 28, 2010 12:20 AM
can a web filter block web page formatting? Hybrid_theory Comments & Feedback 4 Jun 19, 2010 11:21 PM
TPU web Page Refresh Very Slow modder Comments & Feedback 3 Feb 22, 2010 03:30 PM
Building a Web Page Help CybertechComputerz Programming & Webmastering 5 Apr 27, 2009 08:57 AM


All times are GMT. The time now is 02:21 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
no new posts