开发者

file_get_contents not working for some sites

开发者 https://www.devze.com 2023-03-01 18:49 出处:网络
I\'m using file_get_contents to display external content. It works for most websites but then I came across some it didn\'t.

I'm using file_get_contents to display external content.

It works for most websites but then I came across some it didn't.

Here you can see one where it doesn't: http://www.chusmix.com/game/frame.php?url=iknow.jp/home http://www.chusmix.com/game/frame.php?url=twitter.com

It seems the problem has to 开发者_运维知识库do with CSS but I cannot figure out what it is. Also I'm transforming relative paths to absolute ones. However It's not a problem with my code since I tried just the file_get_contents and I still had the issue.

Any ideas of what could be the problem and how to solve it?

Thanks!


It is a problem with your code.

If you look at the source for that japanese site, you'll notice that the URLs are pointing to https://iknow.jp/stylesheets/base_packaged.css but in your frame it's pointing to http://iknow.jp/home/stylesheets/base_packaged.css

Notice the extra /home? It's probably happening when you do the replacements.

The twitter link you posted works for me.


Seems like that site is built on CSS and is not coming along with the fetching.


You are not fetching correct URL for css.

Your given Css Path :: http://iknow.jp/home/stylesheets/base_packaged.css

Correct Url :: http://assets0.iknow.jp/stylesheets/base_packaged.css?1303971324
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号