开发者

Using jquery to get google "results 1-100 of about" ??? "for..." value

I have a question.

How could I get the data from a google search response? I.e.:Results 1 - 100 of about 230,533,709 for blogs. (0.25 seconds)

I want to get the value 230,533,709.

I use php to get the html response from the url. I.e.: http://blogsearch.google.com/blogsearch?hl=en&ie=UTF-8&q=blogs&btnG=Search+Blogs

I use ajax to get the code from php:

$.ajax({
 url: "urlToPhp",
 type: "GET",
 dataType: "html",
 data: $('#form').serialize(),
 beforeSend: function(){}, 
 success: function(html) {
           ->what to do with html to get the value 230,533,709???
$('#results').html(test).show('slow');
}
});

Please help. I don't know how to do this. Regards!


It still doesn't work. Could you please paste the complete code how you get the content and then parse the results value?

I tried this piece of code and doesn't work:

$("#results").load("http://blogsearch.google.com/blogsearch?hl=en&am开发者_JAVA技巧p;ie=UTF-8&q=blogs&btnG=Search+Blogs", function(data){
  alert(data); <- returns empty string
  alert($(data).text()); <-returns null
  alert($(data).find('b:eq(3)')); <- returns "[object Object]"
});

Why data is not the downloaded content. What means [object Object]?

Thank for your help.

Regards!


Have you tried using a selector (not tested, might need top adjust the selector):

var count = $(html).find('table.ttt td.rsb b:nth-child(2)').html();

UPDATE:

adjust the selector:

var count = $(html).find('b:eq(3)').html();


How about this (basedon Darin's answer):

$('table.ttt td.rsb b:nth-child(3)').html();

I got 261,022,603


good idea is -

  1. Take all html
  2. Parse in php $.post() with preg_match()
  3. Got result

Not use jquery against page from google.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜