FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
serpapi-java/src/test/java/serpapi/example/YoutubeTest.java at master · serpapi/serpapi-java · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
serpapi
/
serpapi-java
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
8
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
serpapi-java
/
src
/
test
/
java
/
serpapi
/
example
/
YoutubeTest.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (29 loc) · 890 Bytes
Breadcrumbs
serpapi-java
/
src
/
test
/
java
/
serpapi
/
example
/
YoutubeTest.java
Copy path
File metadata and controls
37 lines (29 loc) · 890 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package
serpapi
.
example
;
import
serpapi
.*;
import
com
.
google
.
gson
.
JsonObject
;
import
com
.
google
.
gson
.
JsonPrimitive
;
import
org
.
junit
.
Test
;
import
java
.
util
.
HashMap
;
import
java
.
util
.
Map
;
import
static
org
.
junit
.
Assert
.*;
/**
* Test main class
*/
public
class
YoutubeTest
{
@
Test
public
void
search
()
throws
SerpApiException
{
// skip test if no api_key provided
if
(
System
.
getenv
(
"SERPAPI_KEY"
) ==
null
)
return
;
// setup serpapi client
Map
<
String
,
String
>
auth
=
new
HashMap
<>();
auth
.
put
(
"api_key"
,
System
.
getenv
(
"SERPAPI_KEY"
));
SerpApi
client
=
new
SerpApi
(
auth
);
// run search
Map
<
String
,
String
>
parameter
=
new
HashMap
<>();
parameter
.
put
(
"engine"
,
"youtube"
);
parameter
.
put
(
"search_query"
,
"coffee"
);
JsonObject
results
=
client
.
search
(
parameter
);
assertTrue
(
results
.
getAsJsonArray
(
"video_results"
).
size
() >
5
);
}
}
Back
|
FazBrowse Home
|
New Git URL