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.

231 Like 24 Dislike
Previous php-forum Next php-forum
Other php-forum

DELETE FROM not working deletes wrong row
Hello

I have the following code which i found but it doesnt work properly.. it comes up with

Reading waves
Hi,

I am trying to find a way of finding the highs and lows on a graph line, the line points

php/xmlrpc class issue
I am working on xml-rpc in php to start with.

I have a class that only has variables defined

Working with popups and such in a class
I've recently started building my applications completely enclosed in classes. I like the fact that

Code clarification
Hi

In the following code what could be the "search_print()" and where it could be

Help with form post data and arrays
Hi all,

I am new to this forum... It has been awhile since i have worked with arrays, and i a

help with variable
I've got a problem, i want to echo some images depending on the $id, however for me to get that id i

Syntax Help
Code:


im having trouble with that code snipped
Parse error: syntax error, unexpec

Error in SQL Syntax HELP!!!
I have this page:

Code: <?php

session_start();

//connect to server and s

Just cannot get 'area' to submit to db using same php code as already used
Basically all i have done is just modified some code and added an area section.
The form is allre

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