php tarama - etkin javascript

1 Cevap php

Bonjour, herkes javascript etkin olmamış gibi davranan bir örümcek yaratmanın bir yolu biliyor mu?

PHP-Kodu:

file_get_contents("http://www.google.co.uk/search?hl=en&q=".$keyword."&start=".($x*10)."&sa=N")

it would retrieve the output of that page. If you used, PHP-Kodu:

file_get_contents("http://www.facebook.com/something/something.something.php") 
(im not sure i just know face book is a good example)

bu tahmin im çizgisinde bir şey içerir, hangi trhe çıktı dönecekti o (erişilebilir değil) bir javascript işletilen site çünkü "sen javascript devam etkin olmalıdır".

EDIT: PHP-Kodu: Just checked

$link = "http://www.facebook.com/index.php";
$contents = file_get_contents($link);
echo $contents;

returns: You are using an incompatible web browser.

Üzgünüz, tarayıcınızı desteklemek için yeterince serin değildi. Aşağıdaki tarayıcılardan biri ile gerçek saklayın:

* Mozilla Firefox
* Safari
* Microsoft Internet Explorer

which i tested through all the above browsers ?

1 Cevap

Görünüşe göre, bu özel durumda, Facebook sadece HTTP Üstbilgi "User-Agent" için test edilmiştir.

Bana kullanarak optons bir çok ayarlamanızı sağlar curl dayalı kod bu bölümünü, istimal ederse curl_setopt :

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.facebook.com/index.php");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$html = curl_exec($ch);
curl_close($ch);
echo $html;

Ben senin gibi aynı mesajı alıyorum.


But, if I try sending a User-Agent that correspond to Firefox (I just copy-pasted the one my real Firefox is actually sending) :

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.facebook.com/index.php");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.3) Gecko/20090910 Ubuntu/9.04 (jaunty) Shiretoko/3.5.3");
$html = curl_exec($ch);
curl_close($ch);
echo $html;

Ben gerçek bir Facebook ana sayfasını değil, uyumsuz tarayıcı hakkında bu hata mesajı alıyorum.


Of course, this will not solve the problem of Javascript not being executed...

Ama ... Bir tarayıcı olmadan Javascript yürütme oldukça zor bir şeydir (not even google solved it ^^ )

Bir tarayıcı olmadan JavaScript kodu çalıştırmasına izin motorlar) PHP için, (rhino, for instance ; or the Spidermonkey PECL extension vardır ; ama onlar Javascript kodu çalıştırmak için izin bile, web dayandığı tarayıcısı tarafından sağlanan tüm çevre ve yöntemleri var olmaz ...


An idea, if you need to crawl a Javascript-dependant website, might be to use Selenium, which opens a real browser (ie, firefox, or other), controling it from your PHP code via Selenium RC.

Ama bu grafiksel bir ortam olması gerektiği anlamına gelir, ve bir tarayıcı, size PHP makinede; Bu da oldukça ağır ve yavaş - sadece ^ ^ Bir web sayfası yüklenirken çok daha yavaş