Solved

Videos on google first page

Posted on 2016-09-15
10
49 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do I remove "" from json_encode 5 35
What is key combo for a b with a forward slash through it? 12 66
How can I split a variable 19 46
Format Date 7 28
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…

752 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