file-get-contents

How to get content from specific tags when using file_get_contents

夙愿已清 提交于 2019-12-06 15:35:07
For example i have one .txt file, called cache.txt. It contains some information, and i need to get content from <span class="date">**THESE**</span> tags. Any ideas? Thanks. You can use Simple HTML DOM Example: cache.txt <span class="abc">Lorem Ipsum</span> <span class="date">THESE</span> <span class="def">Dolor sit amet</span> file.php <?php include 'simple_html_dom.php'; $html = file_get_html('cache.txt'); echo $html->find('span[class=date]',0); //Output: THESE ?> **Check this out it will bring the result** //cache.txt <span class="date">**THESE**</span> //index.php <?php $dom = new

Replace file_get_contents() with cURL?

此生再无相见时 提交于 2019-12-06 13:16:21
I don't want to use this function because to it's unavailability on some servers for security reasons, how can i replace file_get_contents() with cURL ? The line below is causing me a problem on my server : $response = file_get_contents('http://images.google.com/images?hl=en&q=' . urlencode ($query) . '&imgsz=' . $size . '&imgtype=' . $type . '&start=' . (($page - 1) * 21)); How can i replace the line with another one that uses curl so it will work on every server ? here is a clean function you can use $response = get_data('http://images.google.com/images?hl=en&q=' . urlencode ($query) . '

Use PHP to get embed src page information?

。_饼干妹妹 提交于 2019-12-06 12:47:28
Sort of a weird question. From 4shared video site, I get the embed code like the following: <embed src="http://www.4shared.com/embed/436595676/acfa8f75" width="420" height="320" allowfullscreen="true" allowscriptaccess="always"></embed> Now, if I access the url in that embed src, the video is loaded up and the URL of the page is changed with information about the video. I am wondering if there is any way for me to access that info using PHP? I tried file_get_contents but it gives me lots of weird characters. So, can I use PHP to load the embed url and get the information present in the address

Force download mp4 files

帅比萌擦擦* 提交于 2019-12-06 10:16:03
I want to force the user tho download a youtube video. For example this url. I download the video and I can play the original video, but even the length/size of video is the same I cant play it when is force_downloaded. function force_download($file,$video_url) { $video_data = file_get_contents($video_url); file_put_contents($file, $video_data); if(isset($file) && file_exists($file)) { header('Content-length: ' . filesize($file)); header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename= "' . $file . '"'); readfile($file); } } force_download('youtube

Accept cookies using cURL?

蓝咒 提交于 2019-12-06 07:23:08
问题 I've been trying to get the contents of a webpage using cURL, but have trouble getting cURL to accept cookies. For example, on Target.com, when I cURL it, it still says that I have to enable cookies. Here is my code: $url = "http://www.target.com/p/Acer-Gateway-15-6-Laptop-PC-NV57H77u-with-320GB-Hard-Drive-4GB-Memory-Black/-/A-13996190#?lnk=sc_qi_detailbutton"; $ch = curl_init(); // initialize curl handle curl_setopt($ch, CURLOPT_URL,$url); // set url to post to curl_setopt($ch, CURLOPT

php file_get_contents - AFTER javascript executes

瘦欲@ 提交于 2019-12-06 07:18:22
basically, I am trying to scrape webpages with php but I want to do so after the initial javascript on a page executes - I want access to the DOM after initial ajax requests, etc... is there any way to do this? Short answer: no. Scraping a site gives you whatever the server responds with to the HTTP request that you make (from which the "initial" state of the DOM tree is derived, if that content is HTML). It cannot take into account the "current" state of the DOM after it has been modified by Javascript. I'm revising this answer because there are now several projects that do a really good job

PHP file_put_contents save from php file

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 07:14:33
I'm trying to get the Html source code from a php file and put it into an Html file using this: file_put_contents('result.html', file_get_contents('index.php')); After running this function, The "result.html" will contain the same PHP codes in the original "index.php" file, While I need "result.html" file to get the Html code after index.php has executed. Any Help Please?. Thanks. Another way (doesn't need an http server nor access to shell): <?php ob_start(); include('index.php'); $page = ob_get_contents(); ob_end_clean(); file_put_contents('result.html', $page); ?> You are simply copying php

Catching Failed HTTP Request in PHP

点点圈 提交于 2019-12-06 06:12:14
So, I'm having a little bit of trouble in PHP with a file_get_contents... I'm using this code . Before, if I ran it with a hash that it could not find (bdfccf20b1db88d835c27685ac39f874), it would return this: fcf1eed8596699624167416a1e7e122e - found: octopus (Google) bed128365216c019988915ed3add75fb - found: passw0rd (Google) d0763edaa9d9bd2a9516280e9044d885 - found: monkey (Google) dfd8c10c1b9b58c8bf102225ae3be9eb - found: 12081977 (Google) ede6b50e7b5826fe48fc1f0fe772c48f - found: 1q2w3e4r5t6y (Google) bdfccf20b1db88d835c27685ac39f874 Warning: file_get_contents(http://md5.gromweb.com/query

file_get_contents('php://input') keeps returning empty

放肆的年华 提交于 2019-12-06 00:50:35
I'm trying to setup gitkit in my website, but can't get past this one single line of code. No matter what I do, file_get_contents keeps returning empty. I've already set my php.ini : always_populate_raw_post_data = On My environment is PHP 5.3.3 , Apache 2.2.6 , localhost. Here's some code. In my index.php, I call the google API and try to login with gmail account, in other words, federated login. (this is from the Google API Console) <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="//ajax.googleapis

laravel file_get_contents of a route get no response

我与影子孤独终老i 提交于 2019-12-05 23:59:42
I have a route: Route::group(array('prefix' => 'playlist'), function() { Route::get('raw/{id}', array('as'=>'rawPlaylist', 'uses'=>'PlaylistsController@raw')); }); When I open the URL: http://localhost:8000/playlist/raw/1 Everything is fine and the page will load and show me the view. In a controller I get the URL: $url = URL::route('rawPlaylist', 1); The problem: I want read the view and store the whole view into a variable: $html = file_get_contents($url); echo $url is http://localhost:8000/playlist/raw/1 this is right. But this does not work. I get no response, and the php artisan serve