mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +02:00
try to use python.net as the bridge.
This commit is contained in:
@@ -3,22 +3,27 @@ import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import json
|
||||
|
||||
class PyWinAlfred():
|
||||
|
||||
def query(self,key):
|
||||
k = key.split(" ")[1]
|
||||
if not k:
|
||||
return ""
|
||||
r = requests.get('http://movie.douban.com/subject_search?search_text=' + k)
|
||||
bs = BeautifulSoup(r.text)
|
||||
results = []
|
||||
for i in bs.select(".article table .pl2 a"):
|
||||
res = {}
|
||||
t = i.text.strip().replace(" ","")
|
||||
res["Title"] = t.replace("\\n","")
|
||||
results.append(res)
|
||||
return json.dumps(results)
|
||||
def query(key):
|
||||
k = key.split(" ")[1]
|
||||
if not k:
|
||||
return ""
|
||||
r = requests.get('http://movie.douban.com/subject_search?search_text=' + k)
|
||||
bs = BeautifulSoup(r.text)
|
||||
results = []
|
||||
for i in bs.select(".article table .pl2"):
|
||||
res = {}
|
||||
title = i.select("a")[0].text.replace("\n","").replace(" ","")
|
||||
score = i.select("span.rating_nums")[0].text if i.select("span.rating_nums") else "0"
|
||||
res["Title"] = title
|
||||
res["SubTitle"] = score
|
||||
res["ActionName"] = "openUrl"
|
||||
res["ActionPara"] = i.select("a[href]")[0]["href"]
|
||||
results.append(res)
|
||||
return json.dumps(results)
|
||||
|
||||
def openUrl(url):
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
p = PyWinAlfred()
|
||||
print p.query("movie geo")
|
||||
print query("movie geo")
|
||||
|
||||
Reference in New Issue
Block a user