Skip to content

useful google apis for language processing

Notifications You must be signed in to change notification settings

zhichul/pygoogle

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

pygoogle

useful google apis for language processing, support multi cookies to anti CAPTCHA!!!

usage:

from pygoogle.ngram import GNgram
ngram = GNram()
print(ngram("java"))

from pygoogle.search import GSearch
s = GSearch()
print(s("Python"))

from pygoogle.translate import GTranslate
t = GTranslate()
print(t("who"))

for GSearch, if it successed, return generater. the first element in generator is total num of results on google, the second is relative words. the rest are results. if it failed, return dict, {"start": start, "query": query, "status": code}

advanced usage:

from pygoogle.search import GSearch
from pygoogle.utils import user_agents, RandFloat
from pygoogle.cookie_cheat import chrome_cookies, firefox_cookies
with open("test.txt") as fi:
    words = [l.strip() for l in fi]
words = [w for w in words if len(w) > 4]
url = "http://s.bt.gg"
s = GSearch(domain="s.bt.gg", pause=RandFloat(10.0,15.0), use_cookie= [chrome_cookies(url), firefox_cookies(url)])
counts = []
for w in words:
    success = False
    while not success:
        try:
            counts.append(next(s(w, stop = 10, debug=True)))
            success = True
        except Exception as e:
            s.reset_domain()
    print("success num:%d" % len(counts))

About

useful google apis for language processing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%