Solved

Videos on google first page

Posted on 2016-09-15
10
46 Views
Last Modified: 2016-09-16
Hi,

There is any way to get number of videos on first page of google by any custom script or API, when we search by a keyword in google?

For e.g. if I am searching with "jquery tutorial" keyword in google, I can see one video on google search result page so it should return 1, same for other keywords.

Thanks.
0
Comment
Question by:JayDip Dev
  • 5
  • 5
10 Comments
 
LVL 35

Expert Comment

by:Kimputer
ID: 41799544
Enumerate all "vidthumb" on the source, then count unique (since source code may contain two instances of vidthumb1, and two instances of vidthumb4. Still totals 2 videos)
I have no idea why they jump in numbers.
1
 

Author Comment

by:JayDip Dev
ID: 41799636
Hi,

I have try

substr_count( $str, 'vidthumb' );

Open in new window


But it not work.
0
 
LVL 35

Expert Comment

by:Kimputer
ID: 41799645
If possible, post full source code you're working on right now.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:JayDip Dev
ID: 41799675
$google_url = "https://www.google.com/search?q=jquery+tutorial";

$ch = curl_init();
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_URL, $google_url );
$result = curl_exec($ch);
curl_close($ch);

$google_vid = 0;
//$google_vid = substr_count( $result, 'https://www.youtube.com/watch' );
$google_vid = substr_count( $result, 'vidthumb');

echo $google_vid;

Open in new window


Output is: 0
0
 
LVL 35

Accepted Solution

by:
Kimputer earned 500 total points
ID: 41799720
Needed to rework something again (as I said, mostly because of Javascript vs source code).
Obviously, remove the two echo lines for the real result. Right now, it's there so you can verify if the results is true.

<?php

$google_url = "https://www.google.nl/search?client=opera&q=free+how+to+video+episode&sourceid=opera&ie=UTF-8&oe=UTF-8";

$ch = curl_init();
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_URL, $google_url );
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$result = curl_exec($ch);
curl_close($ch);

echo $result;

echo '-----';

$google_vid = 0;
//$google_vid = substr_count( $result, 'https://www.youtube.com/watch' );
$google_vid = substr_count( $result, 'alt="Video');

echo $google_vid;

?>

Open in new window

1
 

Author Comment

by:JayDip Dev
ID: 41799742
I have tried with "web design tutorial" keyword with same code that you given and applied it to here: http://slmp-550-4.slc.westdc.net/~web/google-api/

It give me 1 video as a result instead of 2, please check and suggest.
0
 
LVL 35

Expert Comment

by:Kimputer
ID: 41799754
The result is 1, it's correct. If you see two, it means you're checking with your browser which contains cookies and therefore has different results.
You have to use my original code INCLUDING the test echo's to double check.
0
 

Author Closing Comment

by:JayDip Dev
ID: 41799757
Yes, You are right, it works now.

Thanks a Lot ...
0
 

Author Comment

by:JayDip Dev
ID: 41801304
Hi,

I have got new issue with this method it gives me error from google:

Our systems have detected unusual traffic from your computer network.  This page checks to see if it's really you sending the requests, and not a robot.

please suggest

Thanks
0
 
LVL 35

Expert Comment

by:Kimputer
ID: 41801397
Even if I do hundreds of Google searches in my browser, it won't trip up the system. It probably means you really are doing thousands if not millions of these requests (I saw one search does multiple searches already based on auto complete suggestions?)?
Check this page for more on it:
https://support.google.com/websearch/answer/86640?hl=en

If you are really doing automated searches, instead of human initiated ones (and therefore, much lower volume), you really have a problem. Maybe add some detection mechanism, and maybe you'll be able to temporarily continue searching by opening a Google search on a browser (on the same computer or other computer inside the network), and filling in the CAPTCHA.
If you don't change ANYTHING at all (same volume of searches), this cycle will continue at the same rate, there's no real way to stop it from happening.
If it's really important you get the results, maybe take a look here: https://www.google.com/work/search/products/gss.html#pricing_content
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question