Simple Scraper... Weird Output


Posted on 16th Feb 2014 07:03 pm by admin

Okay, maybe I just need a Blue Monster and some sleep, but....

I'm scraping a ringtone site just so that I can download all of the ringtones and add them to my personal library.

The website's code that I am targeting is:
Code: [Select]<tr><td><a href="/ringtone/527783/"><img src="/img/icon/ringt.jpg" border=0>Jackson 5 - Who's Loving You </a> </td><td align=center><a href="/ringtones/classical/" class=cat_link>Classical</a></td><td align=center><img src="/img/rating/star0.gif" border=0></td><td align="right" class=smgrey2>5 months ago</td><td align="center" class=smgrey2><span class="b">13895</span></td><td align="right"><span class="b"><a href="/profile/stambaugh01">stambaugh01</a></span></td></tr>

I would like for it to output the actual filename which in this case would be 527783. I would also like for it to output the title of the file.

There are about 50 or so listings per page, and would like for it to automatically go to the next page to scrape.

Here is my code:
Code: [Select]<?
$data = @file_get_contents("http://www.XXXXXXXXXXXX.com/ringtones/classical/");

preg_match_all('/href="/ringtone/.*?<img src="/img/icon/ringt.jpg" border=0>([^"]*).*?/"><img src="/img/icon/.*?border=0>([^"]*)</td><td align=center>/is',$data,$out);
// preg_match_all('/href="/ringtone/.*?<img src="/img/icon/ringt.jpg" border=0>([^"]*).*?/"><img src="/img/icon/.*?border=0>([^"]*)</td><td align=center>/is',$data,$out);
if ((isset($out[1]) && isset($out[2])) === FALSE) { // Let's do some error checking to see if there is data to insert into the database. If not let's end the script
break;
}
$d = array_combine($out[1], $out[2]);
// End Error Checking
foreach($d as $k=>$v){
echo $k . " --- " . $v . "
";
}
?>

The output is skipping and only outputting the title of every other row, but now directory name.

Thanks in advance for the help.

No comments posted yet

Your Answer:

Login to answer
231 Like 24 Dislike
Previous forums Next forums
Other forums

Creation of Raw Exposure manually
SAP Gurus

I am creating Raw Exposure ( Hedge management ) thru T Code TEM10 with followin

Displaying data from MySql a different way
Hi all,
I'm pretty new to php and MySql and have hit a problem.

I am able to display data

php title problem
Hi,

I am having a problem managing my page title with PHP.

Currently I have my <

How could I do this?
Ive got a simple lottery game, and am using an sql database to keep track of the numbers bought. But

NOOB needs help with upload file
The intent of this form is to create a folder for a client and upload an image into another folder '

Table trouble
i have been reading the forum for a few weeks and decided to join. i like the format and the advice

error reporting
hey everyone

I have a production server in which I want error reporting but only on some page

Form File Upload
I've read through tons of resources and tutorials and as far as I can tell, my code is accurate, but

Trying to add functions to table
I have this list of characters and I'm trying to figure out what I have to do to put the results of

Relative path
I have a absolute path to an image - like so: C:/Program Files/Apache Software Foundation/Apache2.2/

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash