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
24
Other forums
IMAGE - SERVER SIDE scripting help...
How to receive pixel data of an image and buid a bitmap file on the server using the HTTP POST metho
Do While statement
hi guys,
This may sound trivial but im new to php and as part of an assignmenti have to const
add 20 000 to the rowcnt
Hi ...
I need to add 20 000 to the row count but just cant find a way to do this i am new to php
PHP code for a proxy
I was wondering which function I could use to create an online proxy tool. I was thinking cURL would
Streaming local file from PHP while it’s been written to by a CURL process
I am creating a simple Proxy server for my website. Why I am not using mod_proxy and mod_cache is a
php title problem
Hi,
I am having a problem managing my page title with PHP.
Currently I have my <
Save remote XML to local website folder
Hi, I hope you can help me out. I would like to be able to pull an XML file from another site and t
HELP with mysql_real_escape_string
I'm looking to remove apostrophes completely when someone enters lyrics but don't have a clue how to
Wrong Info sent Using $get in form
Hi i have this code that i tried to make to send some info from one page to aother with lots of ppls
radio button reamains checked
Hello i'm trying to keep the state off my radio buttons so it shows which ones where clicked after t