问题
I'm trying to load a website into a variable. But if I run my code, it returns an other page than I see in my browser.
Here's my code:
$query = $_GET['q'];
$url = 'https://www.google.com/search?q='.str_replace(' ','+',$query);
$doc = file_get_contents($url, false, $context);
echo $doc;
I see a (I guess older and) other version of Google in my website then when I go to Google's website itsself.
Can anyone help me?
Edit
Here are some screenshots: This is my websiteThis is Google
To be more obviously, I want to scrape Google results. But with the file_get_contents function I get strange classes, where I get on the web (https://www.google.com) I see h3-tags.
来源:https://stackoverflow.com/questions/59407885/php-file-get-contents-returns-other-web-page-than-i-see-in-my-browser