A tricky screen scraper

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
btfans
Forum Newbie
Posts: 22
Joined: Thu Jun 10, 2004 10:58 am

A tricky screen scraper

Post by btfans »

PHP question (newbie)

As my Company block this ball result page, I (newbie) write this little php code try
to get the text(not graph) of the page and display using my server:

http://mylink.com/ballr1.php (code as bottom)

The problem is it show very good the first page but not the history data link
that can be enquired inside, because the url became
http://mylink.com/srchRes.asp?srchDate= ... &teamName=

which must be 404 url not found!

My question:
Any advise how the below code can be change such that I can actually get

http://bet.hkjc.com/football/en/results ... &teamName=
and the display on my server again ?? Many Thanks.

ballr1.php

Code: Select all

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Result</title>
</head>
<body>
Result
<hr><br>

<?
	$file = "http://bet.hkjc.com/football/en/results/results.aspx";
	$contents = file($file);
	$size = sizeof($contents);
	for($i = 0; $i < $size; $i++) {
	
	$alldata = $contents[$i];
	echo $alldata; }

?>
</body>
</html>
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Why not just change line 1 of your PHP code to read:

Code: Select all

$file = "http://bet.hkjc.com/football/en/results/srchRes.asp?srchDate=1&fromD=24&fromM=11&fromY=2005&toD=25&toM=11&toY=2005&teamName=";
???

Do you want to just display this page, or be able to display any srchRes.asp results by sending different GET variables?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
btfans
Forum Newbie
Posts: 22
Joined: Thu Jun 10, 2004 10:58 am

Post by btfans »

Understand that:
1) after balr1.php display the site html first time, the history data can be enquired by pressing the 'Search' button inside
but ballr1.php need intercept this button to form a link fist like:
http://mylink.com/ballr1.php?srchRes.as ... &teamName=
but not just
http://mylink.com/srchRes.asp?srchDate= ... &teamName=
2) when the ballr1.php is invoked again with the variable parameters (from/to dates etc.), it need to do something
to change the base url to:
http://bet.hkjc.com/football/en/results ... &teamName=

I am really newbie to php, so appreciated anyone point me the solution code.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

So you want your ballr1.php page to be able to get the search results? Well, if you know the different GET values (such as srchDate, fromD, etc), you can build your query that way.

For example:

Code: Select all

$srchDate = 1;
$fromD = 22;

$url = 'http://bet.hkjc.com/football/en/results/srchRes.asp?srchDate='.$srchDate.'&fromD='.$fromD';
contents = file($url);
//and so on
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
btfans
Forum Newbie
Posts: 22
Joined: Thu Jun 10, 2004 10:58 am

Post by btfans »

Would like you try the link, a search button inside:

http://bet.hkjc.com/football/en/results ... &teamName=

I want my ballr1.php be able to get the history data, but all dates etc are variable, so
I meant I cannot hardcoded before the search button is pressed ... any more hints ?
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

I've changed the title of your post. Please use a descriptive title when asking questions. Thanks!
btfans
Forum Newbie
Posts: 22
Joined: Thu Jun 10, 2004 10:58 am

Post by btfans »

So any one can help on 'any code' I can used to view
the blocked ball pages with those from/to data enquiry
thru the 'Search' button ?

Many Thanks,
btfans
Forum Newbie
Posts: 22
Joined: Thu Jun 10, 2004 10:58 am

Post by btfans »

Pls close it's resolved.
Post Reply