{"id":252,"date":"2010-11-23T18:46:35","date_gmt":"2010-11-23T18:46:35","guid":{"rendered":"http:\/\/www.btb4net.com\/borenblog\/?p=252"},"modified":"2013-02-13T08:49:26","modified_gmt":"2013-02-13T08:49:26","slug":"read-page-content-from-url","status":"publish","type":"post","link":"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/","title":{"rendered":"Read page content from url"},"content":{"rendered":"<p>Small reminder &#8211; how to get content &nbsp;from url:<\/p>\n<p><code>function LoadContents($url, $mode){<br \/>\n\t&nbsp; &nbsp;$HTTPRequest = fopen($url, $mode);<br \/>\n\t&nbsp; &nbsp;$contents = &quot;&quot;;<br \/>\n\t&nbsp; &nbsp;if ($HTTPRequest) {<br \/>\n\t&nbsp; &nbsp;stream_set_timeout($HTTPRequest, 100);<br \/>\n\t&nbsp; &nbsp;do {<br \/>\n\t&nbsp; &nbsp; &nbsp; $data = fread($HTTPRequest, 8192);<br \/>\n\t&nbsp; &nbsp; &nbsp; if (strlen($data) == 0) {<br \/>\n\t&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br \/>\n\t&nbsp; &nbsp; &nbsp; }<br \/>\n\t&nbsp; &nbsp; &nbsp; $contents .= $data;<br \/>\n\t&nbsp; &nbsp;} while(true);<br \/>\n\t&nbsp; &nbsp;fclose($HTTPRequest);<br \/>\n\t&nbsp; &nbsp;}<br \/>\n\t&nbsp; &nbsp;return $contents;<br \/>\n\t}<\/code><\/p>\n<p><code>$contents = LoadContents(&quot;http:\/\/www.google.com&quot;, &quot;r&quot;);<\/code><\/p>\n<p>Binary read(like image, pdf, xml etc.):<\/p>\n<p><code>$contents = LoadContents(&quot;http:\/\/www.some_url\/some_chart_generator_file.php&quot;, &quot;rb&quot;);<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Small reminder &#8211; how to get content &nbsp;from url: function LoadContents($url, $mode){ &nbsp; &nbsp;$HTTPRequest = fopen($url, $mode); &nbsp; &nbsp;$contents = &quot;&quot;; &nbsp; &nbsp;if ($HTTPRequest) { &nbsp; &nbsp;stream_set_timeout($HTTPRequest, 100); &nbsp; &nbsp;do { &nbsp; &nbsp; &nbsp; $data = fread($HTTPRequest, 8192); &nbsp; &nbsp; &nbsp; if (strlen($data) == 0) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break; &nbsp; &nbsp; &nbsp; } [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[10],"tags":[],"class_list":["post-252","post","type-post","status-publish","format-standard","hentry","category-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Read page content from url - Branislav Pavlovic<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Read page content from url - Branislav Pavlovic\" \/>\n<meta property=\"og:description\" content=\"Small reminder &#8211; how to get content &nbsp;from url: function LoadContents($url, $mode){ &nbsp; &nbsp;$HTTPRequest = fopen($url, $mode); &nbsp; &nbsp;$contents = &quot;&quot;; &nbsp; &nbsp;if ($HTTPRequest) { &nbsp; &nbsp;stream_set_timeout($HTTPRequest, 100); &nbsp; &nbsp;do { &nbsp; &nbsp; &nbsp; $data = fread($HTTPRequest, 8192); &nbsp; &nbsp; &nbsp; if (strlen($data) == 0) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break; &nbsp; &nbsp; &nbsp; } [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/\" \/>\n<meta property=\"og:site_name\" content=\"Branislav Pavlovic\" \/>\n<meta property=\"article:published_time\" content=\"2010-11-23T18:46:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-02-13T08:49:26+00:00\" \/>\n<meta name=\"author\" content=\"Pavlovi\u0107 Branislav\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pavlovi\u0107 Branislav\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/\"},\"author\":{\"name\":\"Pavlovi\u0107 Branislav\",\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/#\/schema\/person\/1b2f711186b5e6d2f949b93ce659fa28\"},\"headline\":\"Read page content from url\",\"datePublished\":\"2010-11-23T18:46:35+00:00\",\"dateModified\":\"2013-02-13T08:49:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/\"},\"wordCount\":22,\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/\",\"url\":\"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/\",\"name\":\"Read page content from url - Branislav Pavlovic\",\"isPartOf\":{\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/#website\"},\"datePublished\":\"2010-11-23T18:46:35+00:00\",\"dateModified\":\"2013-02-13T08:49:26+00:00\",\"author\":{\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/#\/schema\/person\/1b2f711186b5e6d2f949b93ce659fa28\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.btb4net.com\/borenblog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Read page content from url\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/#website\",\"url\":\"https:\/\/www.btb4net.com\/borenblog\/\",\"name\":\"Branislav Pavlovic\",\"description\":\"My Portfolio\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.btb4net.com\/borenblog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/#\/schema\/person\/1b2f711186b5e6d2f949b93ce659fa28\",\"name\":\"Pavlovi\u0107 Branislav\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/62c17a10b5883b6f49efea84199811ef?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/62c17a10b5883b6f49efea84199811ef?s=96&d=mm&r=g\",\"caption\":\"Pavlovi\u0107 Branislav\"},\"url\":\"https:\/\/www.btb4net.com\/borenblog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Read page content from url - Branislav Pavlovic","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/","og_locale":"en_US","og_type":"article","og_title":"Read page content from url - Branislav Pavlovic","og_description":"Small reminder &#8211; how to get content &nbsp;from url: function LoadContents($url, $mode){ &nbsp; &nbsp;$HTTPRequest = fopen($url, $mode); &nbsp; &nbsp;$contents = &quot;&quot;; &nbsp; &nbsp;if ($HTTPRequest) { &nbsp; &nbsp;stream_set_timeout($HTTPRequest, 100); &nbsp; &nbsp;do { &nbsp; &nbsp; &nbsp; $data = fread($HTTPRequest, 8192); &nbsp; &nbsp; &nbsp; if (strlen($data) == 0) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break; &nbsp; &nbsp; &nbsp; } [&hellip;]","og_url":"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/","og_site_name":"Branislav Pavlovic","article_published_time":"2010-11-23T18:46:35+00:00","article_modified_time":"2013-02-13T08:49:26+00:00","author":"Pavlovi\u0107 Branislav","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Pavlovi\u0107 Branislav","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/#article","isPartOf":{"@id":"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/"},"author":{"name":"Pavlovi\u0107 Branislav","@id":"https:\/\/www.btb4net.com\/borenblog\/#\/schema\/person\/1b2f711186b5e6d2f949b93ce659fa28"},"headline":"Read page content from url","datePublished":"2010-11-23T18:46:35+00:00","dateModified":"2013-02-13T08:49:26+00:00","mainEntityOfPage":{"@id":"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/"},"wordCount":22,"articleSection":["PHP"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/","url":"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/","name":"Read page content from url - Branislav Pavlovic","isPartOf":{"@id":"https:\/\/www.btb4net.com\/borenblog\/#website"},"datePublished":"2010-11-23T18:46:35+00:00","dateModified":"2013-02-13T08:49:26+00:00","author":{"@id":"https:\/\/www.btb4net.com\/borenblog\/#\/schema\/person\/1b2f711186b5e6d2f949b93ce659fa28"},"breadcrumb":{"@id":"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.btb4net.com\/borenblog\/read-page-content-from-url\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.btb4net.com\/borenblog\/"},{"@type":"ListItem","position":2,"name":"Read page content from url"}]},{"@type":"WebSite","@id":"https:\/\/www.btb4net.com\/borenblog\/#website","url":"https:\/\/www.btb4net.com\/borenblog\/","name":"Branislav Pavlovic","description":"My Portfolio","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.btb4net.com\/borenblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.btb4net.com\/borenblog\/#\/schema\/person\/1b2f711186b5e6d2f949b93ce659fa28","name":"Pavlovi\u0107 Branislav","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.btb4net.com\/borenblog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/62c17a10b5883b6f49efea84199811ef?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/62c17a10b5883b6f49efea84199811ef?s=96&d=mm&r=g","caption":"Pavlovi\u0107 Branislav"},"url":"https:\/\/www.btb4net.com\/borenblog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/posts\/252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/comments?post=252"}],"version-history":[{"count":5,"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/posts\/252\/revisions"}],"predecessor-version":[{"id":350,"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/posts\/252\/revisions\/350"}],"wp:attachment":[{"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/media?parent=252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/categories?post=252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/tags?post=252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}