Jump to content

[SOLVED] Please Help


jeet_0077

Recommended Posts

Hi have a strange situation. I have to parse a file which is having some javascript.

http://www.stickam.com/viewCategorySchedule.do?category=show/css/en/category/show/schedule.css

The above is the URL from which i have to parse the contents. basically this is to get the Feeds from the site.

I have done for XML and HTML but this is something different.

 

If u see the source code of the link u can see it is having something like

 

<script>buildScheduleDiv('scottcam','♫ScottKam♫','http://static.stickam.com/media/image/converted/thumb/1747/9798/9/0d87768c-cfd4-11dc-87c9-b9d39bf5edbe.jpg','165312','Aphex Studio Sessions w/ SCOTTKAM','Updates on my Music','Mon, 04 Feb 2008 21:15:00 +0000','Mon, 04 Feb 2008 23:15:00 +0000');</script>

 

 

<script>buildScheduleDiv('millsyfm','The Lee Mills Show','http://static.stickam.com/media/image/converted/thumb/1747/5197/7/ae54e146-bf71-11dc-a6b7-cbddd6b72ad7.jpg','123373','THE LEE MILLS SHOW','Todays Best Music Mix - Music from all over the globe','Mon, 04 Feb 2008 22:00:00 +0000','Tue, 05 Feb 2008 00:00:00 +0000');</script>

 

 

<script>buildScheduleDiv('faderwaveradio','Faderwave Radio','http://static.stickam.com/media/image/converted/thumb/1740/4491/1/15425039-731f-11dc-861a-2135e338a83b.jpg','110851','DJ Denis/House ','DJ Denis has been interested in DJing ever since he started listening to electronic music about 4 years ago, shortly after he became interested in what it is to be a DJ. After playing for about 3 years now, DJ Denis has come to like all forms of house and trance, and even some breakbeats. His playing history goes back to a multitude of clubs in Delhi, and soon moving to Providence he will be looking to start playing in the clubs regularly there.<br><br>','Mon, 04 Feb 2008 22:00:00 +0000','Mon, 04 Feb 2008 23:00:00 +0000');</script>

 

 

I need to parse the contents available between buildScheduleDiv() so that I can enter the data in the database.

 

If someone have any idea how to do that please help.

 

Currently I am using file_get_contents() to get the content but unable to parse.

 

Thanks in advance...

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/89427-solved-please-help/
Share on other sites

Sasa,

Thanks this works fine now I have the contents in the array.

Now I have the array as:

[1] => buildScheduleDiv('scottcam','♫ScottKam♫','http://static.stickam.com/media/image/converted/thumb/1747/9798/9/0d87768c-cfd4-11dc-87c9-b9d39bf5edbe.jpg','165312','Aphex Studio Sessions w/ SCOTTKAM','Updates on my Music','Mon, 04 Feb 2008 21:15:00 +0000','Mon, 04 Feb 2008 23:15:00 +0000')

 

Here if you can help me as my intention is to get each item from the array. If I store the values in a string variable and I can use string_replace() to get rid of buildScheduleDiv.

But here I have one more problem as I need each value to be entered in the db. Ex:

 

val1 = scottcam

val2 = ScottKam

val3 = http://static.stickam.com/media/image/converted/thumb/1747/9798/9/0d87768c-cfd4-11dc-87c9-b9d39bf5edbe.jpg','165312

and so.

I can not use the explode function in the string as in the description part there may be a comma or in some

other place as well.

If u can figure out what would be the best  thing to do.

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/89427-solved-please-help/#findComment-457967
Share on other sites

try

<?php
$a = file_get_contents('http://www.stickam.com/viewCategorySchedule.do?category=show/css/en/category/show/schedule.css');
preg_match_all('/buildScheduleDiv\(([^)]+)\)/', $a, $b);
$out = array();
for ($i = 1; $i<count($b[1]); $i++){
$out[] = explode(',', str_replace("'",'', $b[1][$i]));
}
print_r($out);
?>

Link to comment
https://forums.phpfreaks.com/topic/89427-solved-please-help/#findComment-458464
Share on other sites

or

<?php
$a = file_get_contents('http://www.stickam.com/viewCategorySchedule.do?category=show/css/en/category/show/schedule.css');
preg_match_all('/buildScheduleDiv\(\'([^\']+)\'\)/', $a, $b);
$out = array();
for ($i = 1; $i<count($b[1]); $i++){
$out[] = explode("','", $b[1][$i]);
}
print_r($out);
?>

Link to comment
https://forums.phpfreaks.com/topic/89427-solved-please-help/#findComment-458648
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.