nhathuy07 commited on
Commit
58cc572
·
verified ·
1 Parent(s): f2607ba

Update imgsearch.py

Browse files
Files changed (1) hide show
  1. imgsearch.py +3 -2
imgsearch.py CHANGED
@@ -2,9 +2,10 @@ import requests
2
  from random import choice
3
  from env import GOOGLE_API_KEY, CX
4
 
5
- def search_img(term):
 
6
  _ret = requests.get(
7
- url=f"https://www.googleapis.com/customsearch/v1?key={GOOGLE_API_KEY}&cx={CX}&q={term}&searchType=image&fields=items(link)"
8
  )
9
  try:
10
  return choice(_ret.json()['items'][:10])['link']
 
2
  from random import choice
3
  from env import GOOGLE_API_KEY, CX
4
 
5
+ def search_img(term, orientation="landscape"):
6
+ _t = f"{orientation} image of {term}"
7
  _ret = requests.get(
8
+ url=f"https://www.googleapis.com/customsearch/v1?key={GOOGLE_API_KEY}&cx={CX}&q={_t}&searchType=image&fields=items(link)"
9
  )
10
  try:
11
  return choice(_ret.json()['items'][:10])['link']