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
login to other site by sending post variables
hey,
here is my problem: my school gave me a mail account for school-stuff use. they mail us
please help
HTML Code:
Code: <span id="ctl00"><span>
Automatic Webpage ??
I have a page www.mysite.com/test.php with a
<form>
<textarea name=&q
Select Rows as Columns..
is there a way to select COLUMN_NAME from user_tab_columns where table_name='TABLENAME';
and ha
login and redirect
hello! can someone help me.. can you give me an idea.. I want to make a login page and redirects it
(sub)screen resize modification doesn't work after ECC 6 EhP 4 installation
Hello,
We have previously extended the size of the custom data tab on PO transaction ME23
Forum tutorial
Im a beginner in PHP. Im making a forum(previous questbook, counter and few others) to learn. For no
controlling/creating accounts with privileges
hi all,
i'm trying to figure out how i can create/control account with privileges, for instance a
creating a 1 to 100 in a table
hi guys I am a newb in php need some help.
I have a table with 1 column and 100 rows and in
passthru() help
Hi everyone,
I'm new to the forum and to PHP. I have some pretty good experience writing shell sc