-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathextension.py
More file actions
31 lines (24 loc) · 789 Bytes
/
extension.py
File metadata and controls
31 lines (24 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import vscode
import webbrowser
import pyperclip as pc
from bs4 import BeautifulSoup
import requests
ext= vscode.Extension(name="StackOnCopy", display_name="StackO'n Copy", version="0.0.1")
@ext.event
def on_activate():
return f"{ext.name} running!"
@ext.command(keybind="ALT+/")
def stack_cpy():
a = pc.paste()
url=f"https://stackoverflow.com/search?q={a}"
webbrowser.open_new_tab(url)
@ext.command(keybind="ALT+E")
def stack_cpy_firstLink():
a= pc.paste()
url=f"https://stackoverflow.com/search?q={a}"
html_text=requests.get(url)
soup=BeautifulSoup(html_text.content, 'lxml')
solutions= soup.find('h3', class_='s-post-summary--content-title')
link_go= solutions.a['href']
webbrowser.open_new_tab(link_go)
vscode.build(ext, publish=True)