file-get-contents

Simple html dom file_get_html not working - is there any workaround?

时光总嘲笑我的痴心妄想 提交于 2019-11-27 01:38:38
<?php // Report all PHP errors (see changelog) error_reporting(E_ALL); include('inc/simple_html_dom.php'); //base url $base = 'https://play.google.com/store/apps'; //home page HTML $html_base = file_get_html( $base ); //get all category links foreach($html_base->find('a') as $element) { echo "<pre>"; print_r( $element->href ); echo "</pre>"; } $html_base->clear(); unset($html_base); ?> I have the above code and I'm trying to get certain elements of the Play Store page but it isn't returning anything. Is it possible that certain PHP functions might be disabled on the server to stop that? The

Get file content from URL?

纵然是瞬间 提交于 2019-11-27 00:32:57
When I use following URL in browser then it prompt me to download a text file with JSOn content. https://chart.googleapis.com/chart?cht=p3&chs=250x100&chd=t:60,40&chl=Hello|World&chof=json (Click above URL see downloaded file content) Now I want to create a php page. I want that when I call this php page, it should call above URL and get content(json format) from file and show it on screen. How can I do this ?? Depending on your PHP configuration, this may be a easy as using: $jsonData = json_decode(file_get_contents('https://chart.googleapis.com/chart?cht=p3&chs=250x100&chd=t:60,40&chl=Hello

file_get_contents with query string

瘦欲@ 提交于 2019-11-26 23:33:00
问题 i am trying to send email from php i have one php file with all values & other php template file. (both files are on same server) i am using file_get_contents to get contents of php template file for example $url="emil_form.php"; $a="uname"; if(($Content = file_get_contents($url. "?uname=".$a)) === false) { $Content = ""; } ...... EMAIL Sending Code .......... and here is code for emil_form.php (email template file) Your Name is : <?php $_GET['uname']; ?> so once i got data in $Content i can

PHP file_get_contents() behaves differently to browser

纵然是瞬间 提交于 2019-11-26 23:10:31
问题 I'm trying to download the contents of a web page using PHP. When I issue the command: $f = file_get_contents("http://mobile.mybustracker.co.uk/mobile.php?searchMode=2"); It returns a page that reports that the server is down. Yet when I paste the same URL into my browser I get the expected page. Does anyone have any idea what's causing this? Does file_get_contents transmit any headers that differentiate it from a browser request? 回答1: Yes, there are differences -- the browser tends to send

How to execute and get content of a .php file in a variable?

折月煮酒 提交于 2019-11-26 23:02:48
问题 I want to get contents of a .php file in a variable on other page. I have two files, myfile1.php and myfile2.php . myfile2.php <?PHP $myvar="prashant"; // echo $myvar; ?> Now I want to get the value echoed by the myfile2.php in an variable in myfile1.php, I have tried the follwing way, but its taking all the contents including php tag () also. <?PHP $root_var .= file_get_contents($_SERVER['DOCUMENT_ROOT']."/myfile2.php", true); ?> Please tell me how I can get contents returned by one PHP file

file_get_contents - failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found

可紊 提交于 2019-11-26 22:52:37
I'm having some weird problems with file_get_contents after moving my site to a new domain. I had to set up a new domain and IP address (using Plesk) to get a new ssl certificate working. Now my file_get_contents calling a script on the same domain is giving me this: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found If I call the same url using file_get_contents on another server it works fine, and if I call www.google.com from the server thats failing that works, so it only seems to be if I call a url on the same sever! I have a feeling it might have something to do with

Parse html table using file_get_contents to php array

邮差的信 提交于 2019-11-26 22:46:33
问题 I am trying to parse the table shown here into a multi-dimensional php array. I am using the following code but for some reason its returning an empty array. After searching around on the web, I found this site which is where I got the parseTable() function from. From reading the comments on that website, I see that the function works perfectly. So I'm assuming there is something wrong with the way I'm getting the HTML code from file_get_contents(). Any thoughts on what I'm doing wrong? <?php

file_get_contents not working?

拟墨画扇 提交于 2019-11-26 22:45:22
This code is not working to server. But It is working to my localhost (xampp) $url = file_get_contents('http://www.site.com/'); $xhtml='|<tr style="background-color:#dddddd;"> <td class="odd" align="left">(.+?)</td><td class="odd">(.+?)</td> </tr>|i'; preg_match_all($xhtml,$url,$score); array_shift($score); echo"<pre>"; print_r($score); echo"</pre>"; It prints another scores when I change the code like this. Because there are two rows like this. It has same codes. by the way below code works to server. $xhtml='|<td class="odd" align="left">(.+?)</td><td class="odd">(.+?)</td>|i'; I need to

Alternative to file_get_contents?

一曲冷凌霜 提交于 2019-11-26 22:42:55
问题 $xml_file = file_get_contents(SITE_PATH . 'cms/data.php'); The problem is that a server has URL file-access disabled. I cannot enable it, its a hosting thing. So the question is this. The data.php file generates xml code. How can I execute this and get the xml data without doing the above method? Is it possible? 回答1: Use cURL. This function is an alternative to file_get_contents . function url_get_contents ($Url) { if (!function_exists('curl_init')){ die('CURL is not installed!'); } $ch =

HTTP request failed! HTTP/1.1 505 HTTP Version Not Supported error

放肆的年华 提交于 2019-11-26 22:00:39
问题 I'm trying to use file_get_contents() to get the response from a server and this error was encountered. Could someone tell me what is the reason and how to fix it? The portion of the code is: $api = "http://smpp5.routesms.com:8080/bulksms/sendsms?username=$username&password=$password&source=$source&destination=$destin&dlr=$dlr&type=$type&message=$message"; $resp = file_get_contents($api); The server responded correctly while I pasted the url in the browser. I learned that this is caused by