file-get-contents

PHP get external page content

泪湿孤枕 提交于 2019-12-12 18:09:01
问题 i get the html from another site with file_get_contens , my question is how can i get a specific tag value? let's say i have: <div id="global"><p class="paragraph">1800</p></div> how can i get paragraph's value? thanks 回答1: If the example is really that trivial you could just use a regular expression. For generic HTML parsing though, PHP has DOM support: $dom = new domDocument(); $dom->loadHTML("<div id=\"global\"><p class=\"paragraph\">1800</p></div>"); echo $dom->getElementsByTagName('p')-

PHP file_get_contents() and XML files [duplicate]

风格不统一 提交于 2019-12-12 17:10:16
问题 This question already has answers here : How to display XML in HTML in PHP? (5 answers) Closed 6 years ago . in PHP I want to load a XML file (as a text file) and show its content (as a text) on a screen. I have a simple XML in the form <root> <parent>Parent text. </parent></root> If I use $myxmlfilecontent = file_get_contents('./myfile.xml'); echo $myfilecontent; prints only the content of the node "parent", it prints only "Parent text.", not the whole file content. 回答1: When you print XML

PHP file_get_contents() follow Content-length header

我怕爱的太早我们不能终老 提交于 2019-12-12 15:57:23
问题 i'm using code like this: //section with the important stuff for the client ob_start(); echo "Blah... Random Content" . rand(1,1000); $size = ob_get_length(); header("Content-Length: $size"); header('Connection: close'); ob_end_flush(); ob_flush(); flush(); //all the following output/script running time should be ignored by the client (file_get_contents()) sleep(10); echo "long action completed"; to output some content and subsequently running a time consuming background job. In a other file

Retrieve value of a textarea with PHP

删除回忆录丶 提交于 2019-12-12 14:01:13
问题 Would anyone perhaps know how to get the value of a specific element in an HTML document with PHP? What I'm doing right now is using file_get_contents to pull up the HTML code from another website, and on that website there is a textarea: <textarea id="body" name="body" rows="12" cols="75" tabindex="1">Hello World!</textarea> What I want to do is have my script do the file_get_contents and just pull out the "Hello World!" from the textarea. Is that possible? Sorry for bugging you guys, again,

PHP File Downloading Questions

社会主义新天地 提交于 2019-12-12 10:08:14
问题 I am currently running into some problems with user's downloading a file stored on my server. I have code set up to auto download a file once the user hits the download button. It is working for all files, but when the size get's larger than 30 MB it is having issues. Is there a limit on user download? Also, I have supplied my example code and am wondering if there is a better practice than using the PHP function 'file_get_contents'. Thank You all for the help! $path = $_SERVER['DOCUMENT_ROOT

PHP can't use file_get_html() in AliExpress

荒凉一梦 提交于 2019-12-12 07:29:23
问题 I have been trying to use file_get_html() in AliExpress but I am getting an error. When I try to use the following, everything works: $url = "http://pt.aliexpress.com/br_home.htm"; $retorno = file_get_html($url); When I try to use this, everything collapses: $url = "http://pt.aliexpress.com/item/2015-Hot-Men-s-Fashion-Casual-Slim-Fit-Suit-Jacket-Solid-Color-High-Quality-Masculine-Blazer/32272100970.html?s=p"; $retorno = file_get_html($url); And I get the error: Warning: file_get_contents(http

Make file_get_contents() wait for website to load completely

柔情痞子 提交于 2019-12-12 06:06:13
问题 I'm trying to get this website into my php variable: https://www.warcraftlogs.com/rankings/server/393/latest/#class=Druid&spec=Feral You can see the website is only starting to load the real contents of the website once the page has finished loading for the first time. file_get_contents("https://www.warcraftlogs.com/rankings/server/393/latest/#class=Druid&spec=Feral"); returns only the stock empty website without the actual contents from the tables that loaded in the second step. Is there a

Update local php file from remote php file

左心房为你撑大大i 提交于 2019-12-12 06:05:57
问题 I am working on a CMS that will be installed for many clients, but as I keep on improving it I make modifications to a few files. I want these updates to be automatically applied to all the projects using the same files. I thought of executing a check file every time the CMS is opened. This file would compare the version of the local file with the remote file, for this I can keep a log or something for the versions, no big deal, but that's not the problem, here is some sample code I thought

Check if a string contains a url and get contents of url php

孤街浪徒 提交于 2019-12-12 04:59:09
问题 Suppose someone enters a string in a textarea like this "The best search engine is www.google.com." or maybe "The best search engine is https://www.google.co.in/?gfe_rd=cr&ei=FLB1U4HHG6aJ8Qfc1YHIBA." Then i want to highlight the link as stackoverflow does. And also i want to file_get_contents to get one image , a short description and title of the page. Most probably i wanna check if the string contains a url or not -> two times. On keyup of textarea using jQuery and therefore using the get

file_get_contents Connection Timed Out for some contents

对着背影说爱祢 提交于 2019-12-12 04:48:00
问题 i'm developing a site in which user can upload pictures. Once users insert the url ( only remote ) of image, i call a ajax to a php that take url and store it to the server. The problem is the file_get_contents: For some images it gives me Connection Timed Out, for other no. Some images that gives me that error are: http://www.lloydsbaiahotel.it/images/bgtop/03.jpg http://www.lloydsbaiahotel.it/images/bgtop/04.jpg I simple try to fetch content in this way: $img = "http://www.lloydsbaiahotel