mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
Add HackerNews python plugin as the Demo.
This commit is contained in:
BIN
Plugins/Wox.Plugin.HackerNews/Images/app.ico
Normal file
BIN
Plugins/Wox.Plugin.HackerNews/Images/app.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.4 KiB |
27
Plugins/Wox.Plugin.HackerNews/main.py
Normal file
27
Plugins/Wox.Plugin.HackerNews/main.py
Normal file
@@ -0,0 +1,27 @@
|
||||
#encoding=utf8
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import json
|
||||
import webbrowser
|
||||
from wox import Wox
|
||||
|
||||
class HackerNews(Wox):
|
||||
|
||||
def query(self,key):
|
||||
r = requests.get('https://news.ycombinator.com/')
|
||||
bs = BeautifulSoup(r.text)
|
||||
results = []
|
||||
for i in bs.select(".comhead"):
|
||||
title = i.previous_sibling.text
|
||||
url = i.previous_sibling["href"]
|
||||
results.append({"Title": title ,"IcoPath":"Images/app.ico","JsonRPCAction":{"method": "openUrl", "parameters": url}})
|
||||
|
||||
return results
|
||||
|
||||
def openUrl(self,url):
|
||||
webbrowser.open(url)
|
||||
|
||||
if __name__ == "__main__":
|
||||
HackerNews()
|
||||
12
Plugins/Wox.Plugin.HackerNews/plugin.json
Normal file
12
Plugins/Wox.Plugin.HackerNews/plugin.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ID":"D2D2C23B084D411DB66FE0C79D6C1B7H",
|
||||
"ActionKeyword":"hn",
|
||||
"Name":"Hacker News",
|
||||
"Description":"Hacker News@https://news.ycombinator.com",
|
||||
"Author":"qianlifeng",
|
||||
"Version":"1.0",
|
||||
"Language":"python",
|
||||
"Website":"http://www.getwox.com",
|
||||
"IcoPath":"Images\\app.ico",
|
||||
"ExecuteFileName":"main.py"
|
||||
}
|
||||
1
Plugins/Wox.Plugin.HackerNews/run.bat
Normal file
1
Plugins/Wox.Plugin.HackerNews/run.bat
Normal file
@@ -0,0 +1 @@
|
||||
d:\Personal\wox.jsonrpc\Output\Debug\PythonHome\python.exe main.py "{\"jsonrpc\": \"2.0\", \"method\": \"query\", \"params\": \"l\", \"id\": 1}
|
||||
Reference in New Issue
Block a user