用php无法获取网页内容,但可以用浏览器访问网页内容,什么情况?
大家根据事实推理一下是什么问题
1、服务器可以用浏览器正常访问目标网页
2、一样的网址用php无法获取网页内容。
测试代码:
<?php$a = file_get_contents('目标网址');var_dump($a);?>
结果如下:
更清晰的图: http://img.bbs.csdn.net/upload/201401/03/1388727791_847070.jpg
无论怎样,始终获得一段js。这段js好像负责转向。
而且这段代码好像是动态的,每次函数名变量名都会自己动态改变,应该是某种软件自动生成的。
3、一样的程序代码,其他服务器可以正常获取到目标网址的网页内容。
根据以上事实,那么可以推断哪里出问题?
目标网站针对服务器做出的限制?还是服务器的配置问题?求 解答!
回复讨论(解决方案)
js 代码是要运行后才会出结果的
你只取得了 js 代码,但并没有运行,如何能得到结果?
js 代码是要运行后才会出结果的
你只取得了 js 代码,但并没有运行,如何能得到结果?
这就是问题所在了。
可能第三条事实我没有描述清楚,第三条测试获取到的网页内容是正常的网页内容。并不是js。
js 代码是要运行后才会出结果的
你只取得了 js 代码,但并没有运行,如何能得到结果?
可以确定是对方开启防采集之类的机制了。因为刚开始可以获取到,随着不断的读取,就没法获取了。
没有人会愿意和你猜谜玩
没有人会愿意和你猜谜玩 谁愿意跟你玩猜谜?我提供的信息很清楚,你没能力回答可以一边玩去。
我也遇到了同样的问题

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.
