file-get-contents

PHP file_get_contents specific encoding

让人想犯罪 __ 提交于 2020-01-06 18:34:50
问题 i have one special issue with file_get_contents in PHP, here is code: $html = file_get_contents("http://www.bratm.sk/trochu-harlem-inspiracie-zaslite-nam-svoj-super-harlem-shake-ak-bude-husty-zverejnime-ho"); it gives me something like this í}KsŰĆŇčÚŽň!Ç& zRŚ|iI[#)öIkI ĆĺăĹŮÝĹÍý_ŐŃâ[EVßîV%Ů˙ëvĎ ř)śG#óčééééÇĚ çáÜöÁÖÉ;¤áˇ,rřĂăçť[DQ5íeaKÓśOśÉ?ě='šL¸ÔöLßä6ľ4mg_!JĂ÷˘Śu:L§án];9ŇÎV+ި1|C in some pages from this page i can get proper encoding and content with iconv, but here im helpless, how can i

file_get_contents with Hash Information Included

蓝咒 提交于 2020-01-06 08:39:19
问题 I have tried many methods to try and get the contents of a url, with the hashes effecting the output. I really am not sure how to explain it, but here's an example... Doing: echo file_get_contents('test.com/whatever.php?t1=1&t2=2#this'); Will return the same results as: echo file_get_contents('test.com/whatever.php?t1=1&t2=2'); Even though if I navigate to it in my web browser, it will make a difference. Of course the urls above aren't the actual one's that I am using, but I hope you get the

Is file_get_contents & file_put_contents reliable or can lead to loss of data? Benchmark results

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-06 06:57:31
问题 I was wondering what happens if multiple scripts are sharing same file. I uploaded the test on remote server, where they use HDD to store data. There were 7 tests total, but the family of 6 are compatible. I have 7 files of different size which I uploaded to server and the test. It is loop which reads and writes data from the files. There is 50 microseconds delay in the loop. The loop repeats 50x. I measure the time needed to perform every circle. The differences in the tests (T): Using file

Google Maps Geocode API only works via browser

南笙酒味 提交于 2020-01-06 01:50:46
问题 I try to retrieve the latitude and longitude data by postalcode/zipcode. This is the URL that I'm using: http://maps.google.com/maps/api/geocode/json?address=9462AA The url returns JSON data (including latitude/longitude values) once I open it via the browser. But when I call the exact same URL via the PHP file_get_contents method, it returns 'ZERO_RESULTS'. $url = 'http://maps.google.com/maps/api/geocode/json?address=9462AA'; $geocode = file_get_contents($url); echo $url; echo $geocode; This

How to make all src strings global in PHP?

ε祈祈猫儿з 提交于 2020-01-05 07:38:53
问题 I am writing a web browser in PHP, for devices (such as the Kindle) which do not support multi-tab browsing. Currently I am reading the page source with file_get_contents(), and then echoing it into the page. My problem is that many pages use local references (such as < img src='image.png>'), so they all point to pages that don't exist. What I want to do is locate all src and href tags and prepend the full web address to any that do not start with "http://" or "https://". How would I do this?

500 internal server error file_get_contents

怎甘沉沦 提交于 2020-01-04 14:00:37
问题 If I try and read a sites' source I sometimes get the following (example URL shown): Warning: file_get_contents(http://www.iwantoneofthose.com/gift-novelty/golf-ball-finding-glasses/10602617.html) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in /home/public_html/pages/scrape.html on line 165 Yet the URL on its own is fine.. why would this happen? I tried the following workaround suggestion but same result: $opts = array('http'=

php file_get_contents - AFTER javascript executes

耗尽温柔 提交于 2020-01-02 11:59:21
问题 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? 回答1: 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

file_get_contents with empty file not working PHP

僤鯓⒐⒋嵵緔 提交于 2020-01-02 04:47:09
问题 I try to use file_get_contents form PHP but it's not working. There is my code : $filename = "/opt/gemel/test.txt"; if($filecontent = file_get_contents($filename)){ $nom = fgets(STDIN); file_put_contents($filename, $nom, FILE_APPEND); } else echo "fail"; And my file test.txt is empty. (0 octets). He exists but he is empty. When i write something into it, my code works perfectly but if he is empty my code echo "fails" Why that, why he can't open the file text.txt ? 回答1: The function file_get

file_get_contents (or curl, or fopen) problem with session data

孤人 提交于 2020-01-01 03:42:11
问题 i have a page that shows a value from session, lets call it www.domain-a.com/master.php and if i type it directly from the browser, it shows me the session value. but when i try to download it with file_get_contents (or other method) from another domain, like www.domain-b.com/slave.php, it is not retrieving the content protected by the session, just a blank page. i know it is because the server-b is trying to retrieve the content, not the user... anyone knows how to tell the domain-a that who

PHP get url with special characters without urlencode:ing them!

浪尽此生 提交于 2019-12-31 02:57:10
问题 I would like file_get_contents to get a url that looks like this: http://wapedia.mobi/sv/Gröt The problem is that it requests (can't post entire link, sorry): ...wapedia.mobi/sv/Gr%C3%B6t which you can see has been urlencoded, that page does not give me any results. How can I do this? 回答1: According to the PHP manual, you must specifically encode a URL if it contains special characters. This means the function itself should do no special encoding. Most likely your URL is being encoded before