LeslieCraft

Honfoglalo google kereso

Jan 10th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. # Matteo Delfavero jan.2019
  2. # honfoglalo.hu
  3.  
  4. from PIL import Image
  5. from bs4 import BeautifulSoup
  6. import requests
  7. import pytesseract
  8. import pyautogui
  9.  
  10. pytesseract.pytesseract.tesseract_cmd = r'<full_path_to_your_tesseract_executable>'
  11. # Example tesseract_cmd = r'C:\Program Files (x86)\Tesseract-OCR\tesseract'
  12.  
  13. def OCRimage():
  14.     #         (x,   y,  width,  height)
  15.     pos = (190, 700, 950, 230)
  16.     return pytesseract.image_to_string(pyautogui.screenshot(region=(pos)))
  17.  
  18. def main(keyword):
  19.     print(keyword + "\n")
  20.     google_search = "https://www.google.co.in/search?client=ubuntu&channel=fs&biw=748&bih=875&source=hp&ei=Ugc4XOStLc7CwQK4jbmACg&q=" + keyword
  21.     url = BeautifulSoup(requests.get(google_search).text, "html.parser").findAll('span', {"class":"st"})
  22.  
  23.     for u in url:
  24.         print(u.text)
  25.         break
  26.  
  27. if __name__ == '__main__':
  28.     main(OCRimage())
Add Comment
Please, Sign In to add comment