Solved

Videos on google first page

Posted on 2016-09-15
10
43 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
is this a cms? 8 60
PHP: Query an Sqlite3 Datatbase return in JSON 6 49
paypal ipn to mysql 3 35
Using javascript confirmation for a delete in mysql 5 30
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

776 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