Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,859 questions

51,780 answers

573 users

How to get the HTML code from a website page with curl in PHP

2 Answers

0 votes
$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, "collectivesolver.com");

curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$html = curl_exec($curl);

curl_close($curl);      

echo $html;


/*
run:

<!DOCTYPE html>\n<html>\n\t<!-- Powered by Question2Answer - 
http://www.question2answer.org/ 
-->\n\t<head>
\n\t\t<meta charset=\"utf-8\">\n\t\t<title>Programming &amp; Software Q&amp;A 
| CollectiveSolver</title>
\n\t\t<meta name=\"description\" content=\"Programming &amp; Software Q&amp;A 
(C#, C, PHP, Java, MySQL, JavaScript, HTML, CSS, WinAPI, win32, SQL, CPP, C++, openGL,  
Software,  Code, VB.NET, Python, HTML5, CSS3, DataBase)\">\n\t\t<link rel=\"stylesheet\" 
href=\"./qa-theme/Snow/qa-styles.css?1.7.0\">\n\t\t<link rel=\"alternate\" 
type=\"application/rss+xml\" 
...

*/ 

 



answered Jun 25, 2015 by avibootz
0 votes
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "seek4info.com") ;
curl_setopt($curl, CURLOPT_TIMEOUT, 15) ;
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true) ;
$html = curl_exec($curl) ;
curl_close($curl) ;

echo $html;

/*
run:

<!DOCTYPE html><html><head>
        <title>Seek.4Info - Relevant Search Engine</title>        
        <meta http-equiv="Content-type" content="text/html; charset=utf-8">
        <meta name="keywords" content="Search, Query, Search Engine, Relevant, Links...
        <meta name="description" content="Relevant Links &amp; Information On Any Keyword">

        <link href="http://seek4info.com/css/style.css" rel="stylesheet" type="text/css">

        <script src="http://www.seek4info.com/js/jquery.js"></script>
...

*/

 



answered Jul 23, 2018 by avibootz

Related questions

1 answer 190 views
3 answers 334 views
1 answer 262 views
1 answer 249 views
1 answer 198 views
...