mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-15 20:19:17 +08:00
30 lines
930 B
Python
30 lines
930 B
Python
#encoding=utf8
|
|
import requests
|
|
from bs4 import BeautifulSoup
|
|
import json
|
|
import webbrowser
|
|
|
|
def safeSelectText(s,path):
|
|
return s.select(path)[0].text if len(s.select(path)) > 0 else ""
|
|
|
|
def query(key):
|
|
r = requests.get('http://www.gewara.com/movie/searchMovie.xhtml')
|
|
bs = BeautifulSoup(r.text)
|
|
results = []
|
|
for i in bs.select(".ui_left .ui_media"):
|
|
res = {}
|
|
score = safeSelectText(i,".grade sub") + safeSelectText(i,".grade sup")
|
|
res["Title"] = safeSelectText(i,".title a") + " / " + score
|
|
res["SubTitle"] = i.select(".ui_text p")[1].text
|
|
res["ActionName"] = "openUrl"
|
|
res["IcoPath"] = "Images\\movies.png"
|
|
res["ActionPara"] = "http://www.gewara.com" + i.select(".title a")[0]["href"]
|
|
results.append(res)
|
|
return json.dumps(results)
|
|
|
|
def openUrl(context,url):
|
|
webbrowser.open(url)
|
|
|
|
if __name__ == "__main__":
|
|
print query("movie geo")
|