Reputation: 647
I wanna rename the filename of documents that I get from crawl a web using simple_html_dom. here's my whole code:
foreach($html->find('h3[class=gs_rt] a') as $link1){
foreach($link1->parent()->parent()->parent()->find('div[class=gs_ggs gs_fl]') as $link2){
$docLink = $link2->first_child();
if(strtolower(substr($docLink->href, strrpos($docLink->href, '.'))) === '.pdf') {
$title = strip_tags($link1->plaintext);
$webLink = strip_tags($link1->href);
$pdfLink = strip_tags($docLink->href);
copy($pdfLink, $savePath . basename($pdfLink));
}
}
}
I wanna rename filename with the title in this line :
copy($pdfLink, $title));
But. it does not work, what's wrong ? please help me
Upvotes: 1
Views: 110
Reputation: 303
It looks like you need to create an object out of $link2 before you can access its properties.
Upvotes: 1