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.

Did you know?Explore Trending and Topic pages for more stories like this.
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

While Problem
i am having a problem with a while statement here is the code
Code: [Select]<?php
sess

BAPI BBP_INB_DELIVERY_CREATE - material number missing in delivery
Hi Experts,

I was able to successfully create an Inbound delivery with reference to a PO

generating all possible random letters
hi'

how can i randomize the letters a,b,c,d,e all possible ways, and i want to print the res

The page should be expire when cilck back button
hi,
i'm new to php world.
i create user registration page.
when i submit it,data goes to my

shoping cart issues
i´ve wrote this and works when i add an item to, my cart, but when i want to add othrer item just

PHP Mysql Staff Induction System
Hi there, I'm pretty new to PHP and Mysql so could really do with being pointed in the right directi

update the selected existing records of database
Hi frndz,
I am new to php and get stuck....

Edit.php > Update.php > Updatea

Trouble checking SESSION cookie
I am trying to use $_SESSION cookies to verify admin privileges .
I don't understand why this is

Polymorphism
Was wondering if someone could explain this a little better to me. I had always assumed that it had

help with mysql_error()
Hi,

I am trying to insert data into a table, but I am not able to insert it. I wanted to see

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