Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7434221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:48:03+00:00 2026-05-29T09:48:03+00:00

i search for links from a website with this code. <?php $ch = curl_init();

  • 0

i search for links from a website with this code.

<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://example.com");
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);
curl_close ($ch);

// search the results from the starting site
if( $result ){
   preg_match_all('/<a href="(http:\/\/www.[^0-9]+.pdf?)"/', $result, $output, PREG_SET_ORDER );
     foreach($output as $item  ){ 
        print_r($item );
      }
}
copy($item, 'file.pdf');
?>

just one pdf links that read. then i need a code to download pdf files that provide by links in php. copy function doesn’t work.
thank you 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:48:03+00:00Added an answer on May 29, 2026 at 9:48 am

    i’ve solved it, using this code, thank you for @Oldskool 🙂 :

    <?php
    set_time_limit(0);
    include 'simple_html_dom.php';
    $url='example.com';
    //set your save path here
    $path = '/home/igos/pdfs/';
    
    $html = file_get_html($url) or die ('invalid url');
    foreach($html->find('a') as $e) {
         $link= $e->href;
         if (preg_match('/\.pdf$/i', $link)) {
              $result[] = $link;
              copy($link, $path . basename($link));
         }
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the TimThumb script ( http://code.google.com/p/timthumb/ ). My images links are generated
I have a website that returns search results from Twitter, written in C# ASP.NET.
hI, I'm trying to get this code from Larry Nyhoff's book to compile in
I have a SQL database of website names/links/keywords. I then PHP query the database,
So I have this website that has a search feature which searches a table
I would want to search up, down, and match case if possible. Even links
Search the web for the phrase I cosay. I run across this phrase being
I'm trying to extract the price from the bellow html page/link using php cURL
I'm launching this big database (1.5+ million records) driven website and I want to
I'm working on a database driven website (I didn't code it, just modifying few

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.